Пример #1
0
        public void LibrariesEmbeddedProperly(BindingProjectType type, bool useProjectReference)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var projects = BindingProjectTests.GenerateTestProject(type, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);

                string appBuildLog = BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, setupDefaultNativeReference: true).Item2;

                AssertNoResourceWithName(tmpDir, projects.Item1.ProjectName, "SimpleClassDylib.dylib");
                AssertFileInBundle(tmpDir, type, "MonoBundle/SimpleClassDylib.dylib");
            });
        }
Пример #2
0
        public void DoesNotSupportLinkWith(BindingProjectType type)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var projects = BindingProjectTests.GenerateTestProject(type, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);

                projects.Item1.LinkWithName = "SimpleClassDylib.dylib";

                string libBuildLog = BindingProjectTests.SetupAndBuildBindingProject(projects.Item1, false, shouldFail: true);
                Assert.True(libBuildLog.Contains("Can't create a binding resource package unless there are native references in the binding project."), $"Did not fail as expected: {TI.PrintRedirectIfLong (libBuildLog)}");
            });
        }
Пример #3
0
        public void CleanShouldRemoveBundle()
        {
            MMPTests.RunMMPTest(tmpDir => {
                var projects = BindingProjectTests.GenerateTestProject(BindingProjectType.Modern, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);

                string libBuildLog = BindingProjectTests.SetupAndBuildBindingProject(projects.Item1, true);

                TI.CleanUnifiedProject(Path.Combine(tmpDir, projects.Item1.ProjectName));
                Assert.False(Directory.Exists(Path.Combine(tmpDir, "bin/Debug/MobileBinding.resources")), "Resource bundle was not cleaned up");
            });
        }
        public void DoesNotSupportLinkWith(BindingProjectType type)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var projects = BindingProjectTests.GenerateTestProject(type, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);

                projects.Item1.LinkWithName = "SimpleClassDylib.dylib";

                var buildResult = BindingProjectTests.SetupAndBuildBindingProject(projects.Item1, false, shouldFail: true);
                buildResult.Messages.AssertError(7068, "Can't create a binding resource package unless there are native references in the binding project.\n        ");
            });
        }
Пример #5
0
        public void FrameworksEmbeddedProperly(BindingProjectType type, bool useProjectReference)
        {
            MMPTests.RunMMPTest(tmpDir => {
                string frameworkPath = FrameworkBuilder.CreateThinFramework(tmpDir);

                var projects = BindingProjectTests.GenerateTestProject(type, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);
                projects.Item1.ItemGroup = NativeReferenceTests.CreateSingleNativeRef(frameworkPath, "Framework");

                string appBuildLog = BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, false).Item2;

                AssertNoResourceWithName(tmpDir, projects.Item1.ProjectName, "Foo");
                AssertFileInBundle(tmpDir, type, "Frameworks/Foo.framework/Foo", assertIsSymLink: true);
            });
        }
Пример #6
0
        public void ShouldNotUnnecessarilyRebuildBindingProject(bool framework)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var projects = BindingProjectTests.GenerateTestProject(BindingProjectType.Modern, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);

                string projectPath               = Path.Combine(tmpDir, "MobileBinding.csproj");
                string bindingFilePath           = Path.Combine(tmpDir, "ApiDefinition.cs");
                const string CreatePackageString = "Creating binding resource package";

                // First build should create a package
                string frameworkPath = null;

                if (framework)
                {
                    frameworkPath             = FrameworkBuilder.CreateThinFramework(tmpDir);
                    projects.Item1.ItemGroup += NativeReferenceTests.CreateSingleNativeRef(Path.GetFullPath(frameworkPath), "Framework");
                }
                string libBuildLog = BindingProjectTests.SetupAndBuildBindingProject(projects.Item1, setupDefaultNativeReference: !framework);

                Assert.True(libBuildLog.Contains(CreatePackageString), $"First build did not create package? {TI.PrintRedirectIfLong (libBuildLog)}");

                // No change build should not
                libBuildLog = TI.BuildProject(projectPath, true);
                Assert.False(libBuildLog.Contains(CreatePackageString), $"Rebuild build did create package? {TI.PrintRedirectIfLong (libBuildLog)}");

                // Touching the binding project should
                Touch(projectPath);
                libBuildLog = TI.BuildProject(projectPath, true);
                Assert.True(libBuildLog.Contains(CreatePackageString), $"Binding Project build did not create package? {TI.PrintRedirectIfLong (libBuildLog)}");

                // Touching the binding file should
                Touch(bindingFilePath);
                libBuildLog = TI.BuildProject(projectPath, true);
                Assert.True(libBuildLog.Contains(CreatePackageString), $"Binding File build did not create package? {TI.PrintRedirectIfLong (libBuildLog)}");

                // No change build should not
                libBuildLog = TI.BuildProject(projectPath, true);
                Assert.False(libBuildLog.Contains(CreatePackageString), $"Second Rebuild build did create package? {TI.PrintRedirectIfLong (libBuildLog)}");

                // Touching native library should
                Touch(framework ? frameworkPath + "/Foo" : NativeReferenceTests.SimpleDylibPath);
                libBuildLog = TI.BuildProject(projectPath, true);
                Assert.True(libBuildLog.Contains(CreatePackageString), $"Native Library build did not create package? {TI.PrintRedirectIfLong (libBuildLog)}");
            });
        }
Пример #7
0
        public void MultipleNativeReferences(bool useProjectReference)
        {
            MMPTests.RunMMPTest(tmpDir => {
                // This is a bit of a hack, you can't just rename dylibs like this
                string secondNativeLibPath = Path.Combine(tmpDir, "SimpleClassDylib2.dylib");
                File.Copy(NativeReferenceTests.SimpleDylibPath, secondNativeLibPath);

                var projects = BindingProjectTests.GenerateTestProject(BindingProjectType.Modern, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);
                projects.Item1.ItemGroup += NativeReferenceTests.CreateSingleNativeRef(secondNativeLibPath, "Dynamic");

                BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, setupDefaultNativeReference: true);

                // manifest and 2 dylibs
                Assert.AreEqual(3, Directory.GetFiles(Path.Combine(tmpDir, "bin/Debug/MobileBinding.resources")).Length);

                // 2 dylibs + libMonoPosixHelper.dylib
                Assert.AreEqual(3, Directory.GetFiles(Path.Combine(tmpDir, "bin/Debug/UnifiedExample.app/Contents/MonoBundle")).Where(x => x.EndsWith(".dylib")).Count());
            });
        }
Пример #8
0
        public void ShouldNotUnnecessarilyRebuildFinalProject(bool useProjectReference, bool framework)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var projects = BindingProjectTests.GenerateTestProject(BindingProjectType.Modern, tmpDir);
                BindingProjectTests.SetNoEmbedding(projects.Item1);

                const string BuildString = "xcrun -sdk macosx clang";

                string frameworkPath = null;
                if (framework)
                {
                    frameworkPath             = FrameworkBuilder.CreateThinFramework(tmpDir);
                    projects.Item1.ItemGroup += NativeReferenceTests.CreateSingleNativeRef(Path.GetFullPath(frameworkPath), "Framework");
                }
                string appBuildLog = BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, setupDefaultNativeReference: !framework).Item2;

                Assert.True(appBuildLog.Contains(BuildString), $"First build did not run mmp? {TI.PrintRedirectIfLong (appBuildLog)}");

                string projectPath = Path.Combine(tmpDir, "UnifiedExample.csproj");
                string mainPath    = Path.Combine(tmpDir, "Main.cs");

                // No change build should not
                string buildLog = TI.BuildProject(projectPath, true);
                Assert.False(buildLog.Contains(BuildString), $"Rebuild ran mmp again? {TI.PrintRedirectIfLong (buildLog)}");

                if (useProjectReference)
                {
                    // Touching the binding definition should
                    Touch(Path.Combine(tmpDir, "ApiDefinition.cs"));
                    buildLog = TI.BuildProject(projectPath, true);
                    Assert.True(buildLog.Contains(BuildString), $"Binding definition build did not run mmp again? {TI.PrintRedirectIfLong (buildLog)}");
                }
                else
                {
                    // Touching the binding assembly should
                    Touch(Path.Combine(tmpDir, "bin/Debug/MobileBinding.dll"));
                    buildLog = TI.BuildProject(projectPath, true);
                    Assert.True(buildLog.Contains(BuildString), $"Binding build did not run mmp again? {TI.PrintRedirectIfLong (buildLog)}");
                }
            });
        }