コード例 #1
0
ファイル: TestBase.cs プロジェクト: tondat/xamarin-macios
        public virtual void Setup()
        {
            var mtouchPaths = SetupProjectPaths("MySingleView");

            MonoTouchProjectBinPath    = mtouchPaths.ProjectBinPath;
            MonoTouchProjectObjPath    = mtouchPaths.ProjectObjPath;
            MonoTouchProjectCSProjPath = mtouchPaths.ProjectCSProjPath;
            MonoTouchProjectPath       = mtouchPaths.ProjectPath;

            AppBundlePath = mtouchPaths.AppBundlePath;

            var libraryPaths = SetupProjectPaths("MyLibrary", "../MySingleView/", false);

            LibraryProjectBinPath    = libraryPaths.ProjectBinPath;
            LibraryProjectObjPath    = libraryPaths.ProjectObjPath;
            LibraryProjectPath       = libraryPaths.ProjectPath;
            LibraryProjectCSProjPath = libraryPaths.ProjectCSProjPath;

            SetupEngine();

            MonoTouchProject         = SetupProject(Engine, MonoTouchProjectCSProjPath);
            MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance();
            LibraryProject           = SetupProject(Engine, LibraryProjectCSProjPath);
            LibraryProjectInstance   = LibraryProject.CreateProjectInstance();

            CleanUp();
        }
コード例 #2
0
        public virtual void Setup()
        {
            var mtouchPaths = SetupProjectPaths("MySingleView");

            MonoTouchProjectBinPath    = mtouchPaths ["project_binpath"];
            MonoTouchProjectObjPath    = mtouchPaths ["project_objpath"];
            MonoTouchProjectCSProjPath = mtouchPaths ["project_csprojpath"];
            MonoTouchProjectPath       = mtouchPaths ["project_path"];

            AppBundlePath = mtouchPaths ["app_bundlepath"];

            var libraryPaths = SetupProjectPaths("MyLibrary", "../MySingleView/", false);

            LibraryProjectBinPath    = libraryPaths ["project_binpath"];
            LibraryProjectObjPath    = libraryPaths ["project_objpath"];
            LibraryProjectPath       = libraryPaths ["project_path"];
            LibraryProjectCSProjPath = libraryPaths ["project_csprojpath"];

            SetupEngine();

            MonoTouchProject         = SetupProject(Engine, MonoTouchProjectCSProjPath);
            MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance();
            LibraryProject           = SetupProject(Engine, LibraryProjectCSProjPath);
            LibraryProjectInstance   = LibraryProject.CreateProjectInstance();

            CleanUp();
        }
コード例 #3
0
        public void DetectAppManifest_ExecutableProject_NoPList()
        {
            RemoveItemsByName(MonoTouchProject, "None");
            MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance();

            RunTarget_WithErrors(MonoTouchProjectInstance, TargetName.DetectAppManifest);
            Assert.That(MonoTouchProjectInstance.GetPropertyValue("_AppManifest"), Is.Null.Or.Empty, "#1");
        }
コード例 #4
0
        public void UnpackLibraryResources_ExecutableProject()
        {
            // We unpack 4 embedded resources from the library project into BundleResources
            RunTarget(MonoTouchProject, TargetName.Build);
            var bundleResources = MonoTouchProject.GetEvaluatedItemsByName("_BundleResourceWithLogicalName").ToArray();

            Assert.IsTrue(bundleResources.Length >= 33, "#1");
        }
コード例 #5
0
        public void PackLibraryResources_ExecutableProject()
        {
            RunTarget(MonoTouchProject, TargetName.PackLibraryResources);
            var embeddedResources = MonoTouchProject.GetEvaluatedItemsByName("EmbeddedResource").ToArray();

            Assert.AreEqual(2, embeddedResources.Length, "#1");
            Assert.IsTrue(embeddedResources.Any(i => i.FinalItemSpec == "LinkedEmbeddedResource.txt"), "#1");
            Assert.IsTrue(embeddedResources.Any(i => i.FinalItemSpec == Path.Combine("Folder", "EmbeddedResource.txt")), "#2");
        }
コード例 #6
0
        public void GenerateBundleName_ExecutableProject()
        {
            // Initially the AssemblyName is set and there is no app bundle dir
            Assert.AreEqual("MySingleView", MonoTouchProject.GetEvaluatedProperty("AssemblyName"), "#1");
            Assert.IsTrue(string.IsNullOrEmpty(MonoTouchProject.GetEvaluatedProperty("AppBundleDir")), "#2");

            // Now we should have an AppBundleDir
            RunTarget(MonoTouchProject, TargetName.GenerateBundleName);
            Assert.AreEqual("bin/iPhoneSimulator/Debug/MySingleView.app", MonoTouchProject.GetEvaluatedProperty("AppBundleDir"), "#3");
        }
コード例 #7
0
        public void DetectAppManifest_ExecutableProject_TwoPLists()
        {
            RemoveItemsByName(MonoTouchProject, "None");
            MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance();

            MonoTouchProjectInstance.AddItem("None", "Fake/Info.plist");
            MonoTouchProjectInstance.AddItem("None", "Info.plist");

            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.DetectAppManifest);
            Assert.AreEqual("Info.plist", MonoTouchProjectInstance.GetPropertyValue("_AppManifest"), "#1");
        }
コード例 #8
0
        public void DetectAppManifest_ExecutableProject_TwoPLists()
        {
            RemoveItemsByName(MonoTouchProject, "None");

            var group = MonoTouchProject.AddNewItemGroup();

            group.AddNewItem("None", "Fake/Info.plist");
            group.AddNewItem("None", "Info.plist");

            RunTarget(MonoTouchProject, TargetName.DetectAppManifest);
            Assert.AreEqual("Info.plist", MonoTouchProject.GetEvaluatedProperty("_AppManifest"), "#1");
        }
コード例 #9
0
        public void BundleResources()
        {
            var    actool = Path.Combine("obj", "iPhoneSimulator", "Debug", "actool", "bundle");
            var    path   = Path.Combine(MonoTouchProjectPath, "Info.plist");
            var    plist  = PDictionary.FromFile(path);
            string ibtool;

            if (AppleSdkSettings.XcodeVersion.Major >= 7)
            {
                ibtool = Path.Combine("obj", "iPhoneSimulator", "Debug", "ibtool-link");
            }
            else
            {
                ibtool = Path.Combine("obj", "iPhoneSimulator", "Debug", "ibtool");
            }

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

            RunTarget(MonoTouchProject, TargetName.CollectBundleResources);

            var bundleItems = MonoTouchProject.GetEvaluatedItemsByName("_BundleResourceWithLogicalName").ToArray();

            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine("Folder", "BundleResource.txt") && i.GetMetadata("LogicalName") == "Folder/BundleResource.txt"), "#1");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine("Folder", "Content.txt") && i.GetMetadata("LogicalName") == "Folder/Content.txt"), "#2");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == "LinkedBundleResource.txt" && i.GetMetadata("LogicalName") == "Folder/LinkedBundleResource.txt"), "#3");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == "LinkedContent.txt" && i.GetMetadata("LogicalName") == "Folder/LinkedContent.txt"), "#4");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "AppIcons29x29.png") && i.GetMetadata("LogicalName") == "AppIcons29x29.png"), "#5");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "*****@*****.**") && i.GetMetadata("LogicalName") == "*****@*****.**"), "#6");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "*****@*****.**") && i.GetMetadata("LogicalName") == "*****@*****.**"), "#7");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "AppIcons57x57.png") && i.GetMetadata("LogicalName") == "AppIcons57x57.png"), "#8");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "*****@*****.**") && i.GetMetadata("LogicalName") == "*****@*****.**"), "#9");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "*****@*****.**") && i.GetMetadata("LogicalName") == "*****@*****.**"), "#10");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "*****@*****.**") && i.GetMetadata("LogicalName") == "*****@*****.**"), "#11");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "LaunchImage.png") && i.GetMetadata("LogicalName") == "LaunchImage.png"), "#12");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(actool, "*****@*****.**") && i.GetMetadata("LogicalName") == "*****@*****.**"), "#13");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "MainStoryboard.storyboardc", "1-view-2.nib") && i.GetMetadata("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib"), "#14");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "MainStoryboard.storyboardc", "Info.plist") && i.GetMetadata("LogicalName") == "MainStoryboard.storyboardc/Info.plist"), "#15");
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib") && i.GetMetadata("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib"), "#16");
            if (bundleItems.Length > ExpectedExecutableBundleResources.Length)
            {
                Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "en.lproj", "TranslatedView.nib", "runtime.nib") && i.GetMetadata("LogicalName") == "en.lproj/TranslatedView.nib/runtime.nib"), "#17");
                Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "FolderView.nib", "runtime.nib") && i.GetMetadata("LogicalName") == "FolderView.nib/runtime.nib"), "#18");
                Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "iPhoneView.nib", "runtime.nib") && i.GetMetadata("LogicalName") == "iPhoneView.nib/runtime.nib"), "#19");
            }
            else
            {
                Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "en.lproj", "TranslatedView.nib") && i.GetMetadata("LogicalName") == "en.lproj/TranslatedView.nib"), "#17");
                Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "FolderView.nib") && i.GetMetadata("LogicalName") == "FolderView.nib"), "#18");
                Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine(ibtool, "iPhoneView.nib") && i.GetMetadata("LogicalName") == "iPhoneView.nib"), "#19");
            }
            Assert.IsTrue(bundleItems.Any(i => i.FinalItemSpec == Path.Combine("Resources", "image.png") && i.GetMetadata("LogicalName") == "image.png"), "#20");
        }
コード例 #10
0
        public void DetectAppManifest_ExecutableProject_LinkedPList()
        {
            string linkedPlist = CreateTempFile(Path.Combine(TempDir, "Linked.plist"));

            RemoveItemsByName(MonoTouchProject, "None");
            var group = MonoTouchProject.AddNewItemGroup();

            group.AddNewItem("None", linkedPlist);
            group.ToArray().Last().SetMetadata("Link", "Info.plist");

            RunTarget(MonoTouchProject, TargetName.DetectAppManifest);
            Assert.AreEqual(linkedPlist, MonoTouchProject.GetEvaluatedProperty("_AppManifest"), "#1");
        }
コード例 #11
0
        public void GetReferencedAssemblies_Executable()
        {
            RunTarget(MonoTouchProject, TargetName.ResolveReferences);
            var references = MonoTouchProject.GetEvaluatedItemsByName("ReferencePath").ToArray();

            Assert.AreEqual(6, references.Length, "#1");
            Assert.IsTrue(references.Any(t => t.Include.Contains("MyLibrary")), "#2");
            Assert.IsTrue(references.Any(t => t.Include.Contains("System")), "#3a");
            Assert.IsTrue(references.Any(t => t.Include.Contains("System.Xml")), "#3b");
            Assert.IsTrue(references.Any(t => t.Include.Contains("System.Core")), "#3c");
            Assert.IsTrue(references.Any(t => t.Include.Contains("mscorlib")), "#3d");
            Assert.IsTrue(references.Any(t => t.Include.Contains("Xamarin.iOS")), "#3e");
        }
コード例 #12
0
        public void DetectAppManifest_ExecutableProject_LogicalNamePList()
        {
            string logicalPlist = CreateTempFile(Path.Combine(TempDir, "Logical.plist"));

            RemoveItemsByName(MonoTouchProject, "None");
            MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance();

            var item = MonoTouchProjectInstance.AddItem("None", logicalPlist);

            item.SetMetadata("LogicalName", "Info.plist");

            RunTargetOnInstance(MonoTouchProjectInstance, TargetName.DetectAppManifest);
            Assert.AreEqual(logicalPlist, MonoTouchProjectInstance.GetPropertyValue("_AppManifest"), "#1");
        }
コード例 #13
0
        public void Disappearing_Content()
        {
            string resource     = Path.Combine(MonoTouchProjectPath, "Folder", "Content.txt");
            string resourceGone = resource + ".disabled";

            try {
                File.Move(resource, resourceGone);
                RunTarget_WithErrors(MonoTouchProject, "_CollectBundleResources");
                var bundleItems = MonoTouchProject.GetEvaluatedItemsByName("_BundleResourceWithLogicalName").ToArray();
                Assert.IsNotNull(bundleItems, "#1");
                Assert.IsTrue(bundleItems.Length >= 17, "#2");
                Assert.IsFalse(bundleItems.Any(i => i.FinalItemSpec == Path.Combine("Folder", "Content.txt")), "#3");
            } finally {
                File.Move(resourceGone, resource);
            }
        }
コード例 #14
0
 public void DetectAppManifest_ExecutableProject_NoPList()
 {
     RemoveItemsByName(MonoTouchProject, "None");
     RunTarget_WithErrors(MonoTouchProject, TargetName.DetectAppManifest);
     Assert.IsNull(MonoTouchProject.GetEvaluatedProperty("_AppManifest"), "#1");
 }
コード例 #15
0
 public void DetectAppManifest_ExecutableProject()
 {
     RunTarget(MonoTouchProject, TargetName.DetectAppManifest);
     Assert.IsNotNull(MonoTouchProject.GetEvaluatedProperty("_AppManifest"), "#1");
 }
コード例 #16
0
 public void OptimizePngs_False()
 {
     MonoTouchProject.AddNewPropertyGroup(true).AddNewProperty("OptimizePNGs", "False");
     OptimizePngs_Core(false);
 }