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

[msbuild/tests] Add ValidateAppBundleTaskTests #42

Merged
merged 1 commit into from
May 11, 2016
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ExtensionTestBase : TestBase {
public string BundlePath;
public string Platform;

public ExtensionTestBase () { }

public ExtensionTestBase (string platform) {
Platform = platform;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.IO;
using NUnit.Framework;
using Xamarin.MacDev;

namespace Xamarin.iOS.Tasks
{
[TestFixture]
public class ValidateAppBundleTaskTests : ExtensionTestBase
{
ValidateAppBundleTask task;

string extensionBundlePath;

string mainAppPlistPath;
string extensionPlistPath;

PDictionary sourcePlist;

public override void Setup ()
{
base.Setup ();

var extensionName = "MyActionExtension";
BuildExtension ("MyTabbedApplication", extensionName, "iPhoneSimulator");

task = CreateTask<ValidateAppBundleTask> ();
task.AppBundlePath = AppBundlePath;
task.SdkIsSimulator = true;
task.TargetFrameworkIdentifier = "Xamarin.iOS";

extensionBundlePath = Path.Combine (AppBundlePath, "PlugIns", extensionName + ".appex");

mainAppPlistPath = Path.Combine (AppBundlePath, "Info.plist");
extensionPlistPath = Path.Combine (extensionBundlePath, "Info.plist");

sourcePlist = PDictionary.FromFile (mainAppPlistPath);
}

[Test]
public void MissingPlist_MainApp ()
{
File.Delete (mainAppPlistPath);
Assert.IsFalse (task.Execute (), "#1");
Assert.IsTrue (Engine.Logger.ErrorEvents.Count > 0, "#2");
}

[Test]
public void MissingPlist_Extension ()
{
File.Delete (extensionPlistPath);
Assert.IsFalse (task.Execute (), "#1");
Assert.IsTrue (Engine.Logger.ErrorEvents.Count > 0, "#2");
}

[Test (Description = "Xambug #38673")]
public void NotMatching_VersionBuildNumbers ()
{
var warningCount = Engine.Logger.WarningsEvents.Count;

// Warning: The App Extension has a CFBundleShortVersionString
// that does not match the main app bundle's CFBundleShortVersionString.
sourcePlist.SetCFBundleShortVersionString ("1");
warningCount++;

// Warning: The App Extension has a CFBundleVersion
// that does not match the main app bundle's CFBundleVersion.
sourcePlist.SetCFBundleVersion ("1");
warningCount++;

sourcePlist.Save (mainAppPlistPath);
Assert.True (task.Execute (), "#1"); // No build error.
Assert.AreEqual (warningCount, Engine.Logger.WarningsEvents.Count, "#2");
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<Compile Include="TaskTests\GeneratePlistTaskTests\GeneratePlistTaskTests_watchOS_WatchKitApp.cs" />
<Compile Include="TaskTests\GeneratePlistTaskTests\GeneratePlistTaskTests_tvOS.cs" />
<Compile Include="TaskTests\SymbolStripTaskTests.cs" />
<Compile Include="TaskTests\ValidateAppBundleTaskTests.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down