Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Import regression test for bug 29730 #3748

Merged
merged 3 commits into from
Oct 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions tests/MSBuildDeviceIntegration/Tests/BugzillaTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Xamarin.ProjectTools;

namespace Xamarin.Android.Build.Tests
{
[SingleThreaded]
public class BugzillaTests : DeviceTest
{
static ProjectBuilder builder;
static XamarinAndroidApplicationProject proj;

[TearDown]
public void Teardown ()
{
if (HasDevices && proj != null)
RunAdbCommand ($"uninstall {proj.PackageName}");

if (TestContext.CurrentContext.Result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Passed
&& builder != null && Directory.Exists (builder.ProjectDirectory))
Directory.Delete (builder.ProjectDirectory, recursive: true);
}

[Test]
public void GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch ([Values (false, true)] bool isRelease)
{
if (!HasDevices)
Assert.Ignore ("Skipping Test. No devices available.");

string expectedLogcatOutput = "Bug 29730: GlobalLayout event handler called!";

proj = new XamarinAndroidApplicationProject () {
IsRelease = isRelease,
};
if (isRelease || !CommercialBuildAvailable) {
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;arm64-v8a;x86");
} else {
proj.AndroidManifest = proj.AndroidManifest.Replace ("<uses-sdk />", "<uses-sdk android:minSdkVersion=\"23\" />");
}
proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_ONCREATE}",
$@"button.ViewTreeObserver.GlobalLayout += Button_ViewTreeObserver_GlobalLayout;
}}
void Button_ViewTreeObserver_GlobalLayout (object sender, EventArgs e)
{{
Android.Util.Log.Debug (""BugzillaTests"", ""{expectedLogcatOutput}"");
");
builder = CreateApkBuilder (Path.Combine ("temp", $"Bug29730-{isRelease}"));
Assert.IsTrue (builder.Install (proj), "Install should have succeeded.");
ClearAdbLogcat ();
AdbStartActivity ($"{proj.PackageName}/{proj.JavaPackageName}.MainActivity");
Assert.IsTrue (MonitorAdbLogcat ((line) => {
return line.Contains (expectedLogcatOutput);
}, Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"), 45), $"Output did not contain {expectedLogcatOutput}!");
}

}
}