Exemple #1
0
        public void AddAppIcon_NoClean()
        {
            var actool    = Path.Combine("obj", "iPhoneSimulator", "Debug", "actool", "bundle");
            var path      = Path.Combine(MonoTouchProjectPath, "Info.plist");
            var plist     = PDictionary.FromFile(path);
            var plistCopy = PDictionary.FromFile(path);

            // Start without app icon.
            plist.Remove("XSAppIconAssets");
            plist.SetMinimumOSVersion("7.0");
            plist.Save(path, true);

            RunTarget(MonoTouchProject, TargetName.CompileImageAssets, 0);

            var bundleItemsNoAppIcon = MonoTouchProjectInstance.GetItems("_BundleResourceWithLogicalName").ToArray();

            Assert.IsFalse(bundleItemsNoAppIcon.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#1");

            // Put a thread.sleep so that we get noticeable timestamps.
            EnsureFilestampChange();

            // Re-save the original plist (adding app icon).
            plistCopy.Save(path, true);

            // Re-run the task with app icon set this time and no clean.
            // The task should be aware the app icon is now being used.
            RunTarget(MonoTouchProject, TargetName.CompileImageAssets, 0);

            var bundleItemsWithAppIcon = MonoTouchProjectInstance.GetItems("_BundleResourceWithLogicalName").ToArray();

            Assert.IsTrue(bundleItemsWithAppIcon.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#2");
        }
        public void UnpackLibraryResources_ExecutableProject()
        {
            // We unpack 4 embedded resources from the library project into BundleResources
            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.Build);
            var bundleResources = MonoTouchProjectInstance.GetItems("_BundleResourceWithLogicalName").ToArray();

            Assert.IsTrue(bundleResources.Length >= 33, "#1");
        }
        public void PackLibraryResources_ExecutableProject()
        {
            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.PackLibraryResources);
            var embeddedResources = MonoTouchProjectInstance.GetItems("EmbeddedResource").ToArray();

            Assert.AreEqual(2, embeddedResources.Length, "#1");
            Assert.IsTrue(embeddedResources.Any(i => i.EvaluatedInclude == "LinkedEmbeddedResource.txt"), "#1");
            Assert.IsTrue(embeddedResources.Any(i => i.EvaluatedInclude == Path.Combine("Folder", "EmbeddedResource.txt")), "#2");
        }
Exemple #4
0
        public void GetReferencedAssemblies_Executable()
        {
            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.ResolveReferences);
            var references = MonoTouchProjectInstance.GetItems("ReferencePath").ToArray();

            Assert.AreEqual(6, references.Length, "#1");
            Assert.IsTrue(references.Any(t => t.EvaluatedInclude.Contains("MyLibrary")), "#2");
            Assert.IsTrue(references.Any(t => t.EvaluatedInclude.Contains("System")), "#3a");
            Assert.IsTrue(references.Any(t => t.EvaluatedInclude.Contains("System.Xml")), "#3b");
            Assert.IsTrue(references.Any(t => t.EvaluatedInclude.Contains("System.Core")), "#3c");
            Assert.IsTrue(references.Any(t => t.EvaluatedInclude.Contains("mscorlib")), "#3d");
            Assert.IsTrue(references.Any(t => t.EvaluatedInclude.Contains("Xamarin.iOS")), "#3e");
        }
        public void Disappearing_Content()
        {
            string resource     = Path.Combine(MonoTouchProjectPath, "Folder", "Content.txt");
            string resourceGone = resource + ".disabled";

            try {
                File.Move(resource, resourceGone);
                RunTarget_WithErrors(MonoTouchProjectInstance, "_CollectBundleResources");
                var bundleItems = MonoTouchProjectInstance.GetItems("_BundleResourceWithLogicalName").ToArray();
                Assert.IsNotNull(bundleItems, "#1");
                Assert.IsTrue(bundleItems.Length >= 17, "#2");
                Assert.IsFalse(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine("Folder", "Content.txt")), "#3");
            } finally {
                File.Move(resourceGone, resource);
            }
        }
        public void BundleResources()
        {
            var actool = Path.Combine("obj", "iPhoneSimulator", "Debug", "actool", "bundle");
            var ibtool = Path.Combine("obj", "iPhoneSimulator", "Debug", "ibtool");
            var path   = Path.Combine(MonoTouchProjectPath, "Info.plist");
            var plist  = PDictionary.FromFile(path);

            plist.SetMinimumOSVersion("7.0");
            plist.Save(path, true);

            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.CollectBundleResources);

            var bundleItems = MonoTouchProjectInstance.GetItems("_BundleResourceWithLogicalName").ToArray();

            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine("Folder", "BundleResource.txt") && i.GetMetadataValue("LogicalName") == "Folder/BundleResource.txt"), "#1");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine("Folder", "Content.txt") && i.GetMetadataValue("LogicalName") == "Folder/Content.txt"), "#2");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == "LinkedBundleResource.txt" && i.GetMetadataValue("LogicalName") == "Folder/LinkedBundleResource.txt"), "#3");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == "LinkedContent.txt" && i.GetMetadataValue("LogicalName") == "Folder/LinkedContent.txt"), "#4");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "AppIcons29x29.png") && i.GetMetadataValue("LogicalName") == "AppIcons29x29.png"), "#5");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#6");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#7");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "AppIcons57x57.png") && i.GetMetadataValue("LogicalName") == "AppIcons57x57.png"), "#8");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#9");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#10");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#11");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "LaunchImage.png") && i.GetMetadataValue("LogicalName") == "LaunchImage.png"), "#12");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(actool, "*****@*****.**") && i.GetMetadataValue("LogicalName") == "*****@*****.**"), "#13");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "MainStoryboard.storyboardc", "1-view-2.nib", "objects-13.0+.nib") && i.GetMetadataValue("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib/objects-13.0+.nib"), "#14.1");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "MainStoryboard.storyboardc", "1-view-2.nib", "runtime.nib") && i.GetMetadataValue("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib/runtime.nib"), "#14.2");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "MainStoryboard.storyboardc", "Info.plist") && i.GetMetadataValue("LogicalName") == "MainStoryboard.storyboardc/Info.plist"), "#15");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib", "objects-13.0+.nib") && i.GetMetadataValue("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib/objects-13.0+.nib"), "#16.1");
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib", "runtime.nib") && i.GetMetadataValue("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib/runtime.nib"), "#16.2");
            if (bundleItems.Length > ExpectedExecutableBundleResources.Length)
            {
                Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "en.lproj", "TranslatedView.nib", "runtime.nib") && i.GetMetadataValue("LogicalName") == "en.lproj/TranslatedView.nib/runtime.nib"), "#17");
                Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "FolderView.nib", "runtime.nib") && i.GetMetadataValue("LogicalName") == "FolderView.nib/runtime.nib"), "#18");
                Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "iPhoneView.nib", "runtime.nib") && i.GetMetadataValue("LogicalName") == "iPhoneView.nib/runtime.nib"), "#19");
            }
            else
            {
                Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "en.lproj", "TranslatedView.nib") && i.GetMetadataValue("LogicalName") == "en.lproj/TranslatedView.nib"), "#17");
                Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "FolderView.nib") && i.GetMetadataValue("LogicalName") == "FolderView.nib"), "#18");
                Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine(ibtool, "iPhoneView.nib") && i.GetMetadataValue("LogicalName") == "iPhoneView.nib"), "#19");
            }
            Assert.IsTrue(bundleItems.Any(i => i.EvaluatedInclude == Path.Combine("Resources", "image.png") && i.GetMetadataValue("LogicalName") == "image.png"), "#20");
        }
        public void GetReferencedAssemblies_Executable()
        {
            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.ResolveReferences);
            var references          = MonoTouchProjectInstance.GetItems("ReferencePath").ToArray();
            var expected_references = new string[] {
                "MyLibrary.dll",
                "System.dll",
                "System.Xml.dll",
                "System.Core.dll",
                "mscorlib.dll",
                "Xamarin.iOS.dll",
                "System.Drawing.Common.dll",
            };

            Array.Sort(expected_references);

            var actual_references = references.Select((v) => Path.GetFileName(v.EvaluatedInclude)).OrderBy((v) => v);

            CollectionAssert.AreEquivalent(expected_references, actual_references, "References");
        }