Пример #1
0
        public void TestLaunchInvalidValues()
        {
            var path = Path.GetTempFileName();

            Assert.Throws <ArgumentNullException> (() => LaunchServices.OpenApplication((ApplicationStartInfo)null));
            Assert.Throws <ArgumentException> (() => LaunchServices.OpenApplication(path));
        }
Пример #2
0
        public IEnumerable <AbsoluteDirectoryPath> GetApplications(string identifier)
        {
            var appUrls = LaunchServices.GetApplicationUrlsForBundleIdentifier(new NSString(identifier));

            if (appUrls == null)
            {
                return(Enumerable.Empty <AbsoluteDirectoryPath>());
            }
            return(appUrls.Select(p => AbsoluteDirectoryPath.Parse(p.Path)));
        }
Пример #3
0
        public void TestLaunchProcessAPIsForInvalidAppBundles()
        {
            var path = Util.CreateTmpDir("NonExisting.app");

            Assert.AreEqual(-1, LaunchServices.OpenApplication(path));
            Assert.AreEqual(-1, LaunchServices.OpenApplication(new ApplicationStartInfo(path)));

            NSRunningApplication app = LaunchServices.OpenApplicationInternal(new ApplicationStartInfo(path));

            Assert.IsNull(app);
        }
Пример #4
0
        public void TestLaunchProcessAndTerminate()
        {
            NSRunningApplication app = LaunchServices.OpenApplicationInternal(new ApplicationStartInfo("/Applications/Calculator.app"));

            try {
                Assert.IsNotNull(app);
                Assert.That(app.ProcessIdentifier, Is.GreaterThan(-1));
            } finally {
                Assert.IsTrue(app.Terminate(), "Could not kill Calculator app");
            }
        }
Пример #5
0
        public void TestLaunchProcess()
        {
            int pid = LaunchServices.OpenApplication("/Applications/Calculator.app");

            Assert.Greater(-1, pid);
        }