Ejemplo n.º 1
0
        public Task <TestServer> Start(CancellationToken cancellationToken)
        {
            var app       = AppDelegate.Instance.MacUI;
            var framework = TestFramework.GetLocalFramework(app.PackageName, typeof(BuiltinTestServer).Assembly);

            return(TestServer.StartLocal(app, framework, cancellationToken));
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var options = Intent.GetStringExtra("XAMARIN_ASYNCTESTS_OPTIONS");

            if (string.IsNullOrEmpty(options))
            {
                options = "--category=Global";
            }

            Forms.Init(this, bundle);

            var setup = new BtlsDroidFrameworkSetup();

            DependencyInjector.RegisterDependency <IConnectionFrameworkSetup> (() => setup);
            DependencyInjector.RegisterDependency <IMonoConnectionFrameworkSetup> (() => setup);

            DependencyInjector.RegisterAssembly(typeof(WebDependencyProvider).Assembly);
            DependencyInjector.RegisterAssembly(typeof(MainActivity).Assembly);

            Framework = TestFramework.GetLocalFramework(typeof(MainActivity).Assembly);

            var mobileTestApp = new MobileFormsTestApp(Framework, options);

            // mobileTestApp.App.FinishedEvent += (sender, e) => TerminateWithSuccess ();

            LoadApplication(mobileTestApp);
        }
Ejemplo n.º 3
0
        public static TestFramework GetFramework()
        {
            DependencyInjector.RegisterAssembly(typeof(WebDependencyProvider).Assembly);
            DependencyInjector.RegisterAssembly(typeof(NewTlsDependencyProvider).Assembly);

            return(TestFramework.GetLocalFramework(typeof(NewTlsTestFeatures).Assembly));
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Forms.Init(this, bundle);

            DependencyInjector.RegisterAssembly(typeof(NewTlsDependencyProvider).Assembly);

            Framework = TestFramework.GetLocalFramework(typeof(NewTlsDependencyProvider).Assembly);

            LoadApplication(new MobileTestApp(Framework));
        }
Ejemplo n.º 5
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            var setup = new MobileFrameworkSetup();

            DependencyInjector.RegisterDependency <IConnectionFrameworkSetup> (() => setup);
            DependencyInjector.RegisterDependency <IMonoConnectionFrameworkSetup> (() => setup);

            DependencyInjector.RegisterAssembly(typeof(WebDependencyProvider).Assembly);
            DependencyInjector.RegisterAssembly(typeof(AppDelegate).Assembly);

            Framework = TestFramework.GetLocalFramework(typeof(AppDelegate).Assembly);

            return(true);
        }
Ejemplo n.º 6
0
        public TestRunner()
        {
            rng = RandomNumberGenerator.Create();

            MonoTlsProviderFactory.InstallProvider(new NewTlsProvider());

            PortableSupportImpl.Initialize();
            DependencyInjector.Register <ICryptoProvider> (this);
            DependencyInjector.Register <IConnectionProvider> (this);

            Settings = SettingsBag.CreateDefault();
            var assembly = typeof(NewTlsTestFeatures).Assembly;

            Logger = new TestLogger(new MyLogger(this));

            framework = TestFramework.GetLocalFramework(assembly);
        }
Ejemplo n.º 7
0
        Program(string[] args)
        {
            rng = RandomNumberGenerator.Create();

            DependencyInjector.Register <ICryptoProvider> (this);
            DependencyInjector.Register <IConnectionProvider> (this);

            MonoTlsProviderFactory.InstallProvider(new NewTlsProvider());

            LogLevel = -1;

            var p = new OptionSet();

            p.Add("settings=", v => SettingsFile = v);
            p.Add("server", v => Server          = true);
            p.Add("noxml", v => NoXml            = true);
            p.Add("log-level=", v => LogLevel    = int.Parse(v));
            var remaining = p.Parse(args);

            settings = LoadSettings(SettingsFile);

            Assembly assembly;

            if (remaining.Count == 1)
            {
                assembly = Assembly.LoadFile(remaining [0]);
            }
            else if (remaining.Count == 0)
            {
                assembly = typeof(NewTlsTestFeatures).Assembly;
            }
            else
            {
                throw new InvalidOperationException();
            }

            logger          = new TestLogger(new ConsoleLogger(this));
            logger.LogLevel = LogLevel;

            framework = TestFramework.GetLocalFramework(assembly);
        }
Ejemplo n.º 8
0
        async Task <bool> RunLocal(CancellationToken cancellationToken)
        {
            var framework = TestFramework.GetLocalFramework(Assembly, dependencyAssemblies);

            cancellationToken.ThrowIfCancellationRequested();
            session = TestSession.CreateLocal(this, framework);
            OnSessionCreated(session);

            var test = session.RootTestCase;

            Debug("Got test: {0}", test);
            startTime = DateTime.Now;
            result    = await session.Run(test, cancellationToken);

            endTime = DateTime.Now;
            Debug("Got result: {0}", result);

            SaveResult();

            return(IsSuccessResult);
        }
Ejemplo n.º 9
0
        async Task <int> RunLocal(CancellationToken cancellationToken)
        {
            var framework = TestFramework.GetLocalFramework(PackageName, Assembly, Options.Dependencies);

            cancellationToken.ThrowIfCancellationRequested();
            session = TestSession.CreateLocal(this, framework);
            Options.UpdateConfiguration(session);

            var test = session.RootTestCase;

            Debug("Got test: {0}", test.Path.FullName);
            startTime = DateTime.Now;
            result    = await session.Run(test, cancellationToken);

            endTime = DateTime.Now;
            Debug("Got result: {0} {1}", result.Status, test.Path.FullName);

            SaveResult();

            return(ExitCodeForResult);
        }
Ejemplo n.º 10
0
        async void StartWithOptions()
        {
            await Task.Yield();

            if (Options.SessionMode == MobileSessionMode.Local)
            {
                StartServer();
                return;
            }

            if (Options.SessionMode != MobileSessionMode.Connect)
            {
                throw new NotImplementedException();
            }

            var framework = TestFramework.GetLocalFramework(Options.PackageName ?? MacUI.PackageName, typeof(AppDelegate).Assembly);

            Console.WriteLine("Connecting to {0}:{1}.", Options.EndPoint.Address, options.EndPoint.Port);

            var server = await TestServer.ConnectToRemote(ui, Options.EndPoint, framework, CancellationToken.None);

            var session = server.Session;

            Console.WriteLine("Got test session {0} from {1}.", session.Name, server.App);

            var running = await server.WaitForExit(CancellationToken.None);

            Console.WriteLine("Wait for exit: {0}", running);

            try {
                await server.Stop(CancellationToken.None);
            } catch (Exception ex) {
                Console.WriteLine("Failed to stop server: {0}", ex.Message);
            }

            Console.WriteLine("Done running.");
            Environment.Exit(0);
        }
Ejemplo n.º 11
0
        async void StartWithOptions(string options)
        {
            await Task.Yield();

            var args = options.Split(' ');

            if (args.Length < 2 || args [0] != "connect")
            {
                throw new NotImplementedException();
            }

            var framework = TestFramework.GetLocalFramework(typeof(AppDelegate).Assembly);

            var endpoint = DependencyInjector.Get <IPortableEndPointSupport> ().ParseEndpoint(args [1]);

            Console.WriteLine("Connecting to {0}:{1}.", endpoint.Address, endpoint.Port);

            var server = await TestServer.ConnectToRemote(ui, endpoint, framework, CancellationToken.None);

            var session = server.Session;

            Console.WriteLine("Got test session {0} from {1}.", session.Name, server.App);

            var running = await server.WaitForExit(CancellationToken.None);

            Console.WriteLine("Wait for exit: {0}", running);

            try {
                await server.Stop(CancellationToken.None);
            } catch (Exception ex) {
                Console.WriteLine("Failed to stop server: {0}", ex.Message);
            }

            Console.WriteLine("Done running.");
            Environment.Exit(0);
        }
Ejemplo n.º 12
0
        async Task <bool> ConnectToGui(CancellationToken cancellationToken)
        {
            var framework = TestFramework.GetLocalFramework(Assembly, dependencyAssemblies);

            TestServer server;

            try {
                var endpoint = GetPortableEndPoint(GuiEndPoint);
                server = await TestServer.ConnectToGui(this, endpoint, framework, cancellationToken);
            } catch (SocketException ex) {
                if (ex.SocketErrorCode == SocketError.ConnectionRefused && optionalGui)
                {
                    return(await RunLocal(cancellationToken));
                }
                throw;
            }

            OnSessionCreated(server.Session);

            cancellationToken.ThrowIfCancellationRequested();
            await server.WaitForExit(cancellationToken);

            return(true);
        }
Ejemplo n.º 13
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary dict)
        {
            Forms.Init();

            var setup = new MobileFrameworkSetup();

            DependencyInjector.RegisterDependency <IConnectionFrameworkSetup> (() => setup);
            DependencyInjector.RegisterDependency <IMonoConnectionFrameworkSetup> (() => setup);

            DependencyInjector.RegisterAssembly(typeof(WebDependencyProvider).Assembly);
            DependencyInjector.RegisterAssembly(typeof(AppDelegate).Assembly);

            Framework = TestFramework.GetLocalFramework(typeof(AppDelegate).Assembly);

            var options = Environment.GetEnvironmentVariable("XAMARIN_ASYNCTESTS_OPTIONS");

            var mobileTestApp = new MobileFormsTestApp(Framework, options);

            mobileTestApp.App.FinishedEvent += (sender, e) => TerminateWithSuccess();

            LoadApplication(mobileTestApp);

            return(base.FinishedLaunching(app, dict));
        }
Ejemplo n.º 14
0
        async Task <int> ConnectToGui(CancellationToken cancellationToken)
        {
            var framework = TestFramework.GetLocalFramework(PackageName, Assembly, Options.Dependencies);

            TestServer server;

            try {
                var endpoint = GetPortableEndPoint(Options.GuiEndPoint);
                server = await TestServer.ConnectToGui(this, endpoint, framework, cancellationToken);
            } catch (SocketException ex) {
                if (ex.SocketErrorCode == SocketError.ConnectionRefused && Options.OptionalGui)
                {
                    return(await RunLocal(cancellationToken));
                }
                throw;
            }

            Options.UpdateConfiguration(server.Session);

            cancellationToken.ThrowIfCancellationRequested();
            await server.WaitForExit(cancellationToken);

            return(0);
        }