示例#1
0
        public TouchRunner(UIWindow window)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            this.window = window;
            options     = new TouchOptions();
        }
示例#2
0
        public bool OpenWriter(string message)
        {
            TouchOptions options = TouchOptions.Current;
            DateTime     now     = DateTime.Now;

            // let the application provide it's own TextWriter to ease automation with AutoStart property
            if (Writer == null)
            {
                if (options.ShowUseNetworkLogger)
                {
                    var hostname = SelectHostName(options.HostName.Split(','), options.HostPort);

                    if (hostname != null)
                    {
                        Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                        try {
                            Writer = new TcpTextWriter(hostname, options.HostPort);
                        }
                        catch (SocketException) {
                            UIAlertView alert = new UIAlertView("Network Error",
                                                                String.Format("Cannot connect to {0}:{1}. Continue on console ?", hostname, options.HostPort),
                                                                null, "Cancel", "Continue");
                            int button = -1;
                            alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
                                button = (int)e.ButtonIndex;
                            };
                            alert.Show();
                            while (button == -1)
                            {
                                NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow(0.5));
                            }
                            Console.WriteLine(button);
                            Console.WriteLine("[Host unreachable: {0}]", button == 0 ? "Execution cancelled" : "Switching to console output");
                            if (button == 0)
                            {
                                return(false);
                            }
                            else
                            {
                                Writer = Console.Out;
                            }
                        }
                    }
                }
                else
                {
                    Writer = Console.Out;
                }
            }

            Writer.WriteLine("[Runner executing:\t{0}]", message);
            Writer.WriteLine("[MonoTouch Version:\t{0}]", Constants.Version);
            Writer.WriteLine("[Assembly:\t{0}.dll ({1} bits)]", typeof(NSObject).Assembly.GetName().Name, IntPtr.Size * 8);
            Writer.WriteLine("[GC:\t{0}{1}]", GC.MaxGeneration == 0 ? "Boehm": "sgen",
                             NSObject.IsNewRefcountEnabled() ? "+NewRefCount" : String.Empty);
            UIDevice device = UIDevice.CurrentDevice;

            Writer.WriteLine("[{0}:\t{1} v{2}]", device.Model, device.SystemName, device.SystemVersion);
            Writer.WriteLine("[Device Name:\t{0}]", device.Name);
            Writer.WriteLine("[Device UDID:\t{0}]", UniqueIdentifier);
            Writer.WriteLine("[Device Locale:\t{0}]", NSLocale.CurrentLocale.Identifier);
            Writer.WriteLine("[Device Date/Time:\t{0}]", now);              // to match earlier C.WL output

            Writer.WriteLine("[Bundle:\t{0}]", NSBundle.MainBundle.BundleIdentifier);
            // FIXME: add data about how the app was compiled (e.g. ARMvX, LLVM, GC and Linker options)
            passed       = 0;
            ignored      = 0;
            failed       = 0;
            inconclusive = 0;
            return(true);
        }
示例#3
0
        public bool OpenWriter(string message)
        {
            TouchOptions options = TouchOptions.Current;
            DateTime     now     = DateTime.Now;

            // let the application provide it's own TextWriter to ease automation with AutoStart property
            if (Writer == null)
            {
                if (options.ShowUseNetworkLogger)
                {
                    try {
                        string hostname = null;
                        WriterFinishedTask = null;
                        TextWriter defaultWriter = null;
                        switch (options.Transport)
                        {
                        case "FILE":
                            Console.WriteLine("[{0}] Sending '{1}' results to the file {2}", now, message, options.LogFile);
                            defaultWriter = new StreamWriter(options.LogFile, true, System.Text.Encoding.UTF8)
                            {
                                AutoFlush = true,
                            };
                            break;

                        case "HTTP":
                            var hostnames = options.HostName.Split(',');
                            hostname = hostnames [0];
                            if (hostnames.Length > 1)
                            {
                                Console.WriteLine("[{0}] Found multiple host names ({1}); will only try sending to the first ({2})", now, options.HostName, hostname);
                            }
                            Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                            var w = new HttpTextWriter()
                            {
                                HostName = hostname,
                                Port     = options.HostPort,
                            };
                            w.Open();
                            defaultWriter      = w;
                            WriterFinishedTask = w.FinishedTask;
                            break;

                        default:
                            Console.WriteLine("Unknown transport '{0}': switching to default (TCP)", options.Transport);
                            goto case "TCP";

                        case "TCP":
                            hostname = SelectHostName(options.HostName.Split(','), options.HostPort);
                            if (string.IsNullOrEmpty(hostname))
                            {
                                break;
                            }
                            Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                            defaultWriter = new TcpTextWriter(hostname, options.HostPort);
                            break;
                        }
                        if (options.EnableXml)
                        {
                            Writer = new NUnitOutputTextWriter(
                                this, defaultWriter, new NUnitLite.Runner.NUnit2XmlOutputWriter(DateTime.UtcNow), options.XmlMode);
                        }
                        else
                        {
                            Writer = defaultWriter;
                        }
                    } catch (Exception ex) {
                        connection_failure = true;
                        if (!ShowConnectionErrorAlert(options.HostName, options.HostPort, ex))
                        {
                            return(false);
                        }

                        Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", options.HostName, options.HostPort, ex);
                        Writer = Console.Out;
                    }
                }
            }

            if (Writer == null)
            {
                Writer = Console.Out;
            }

            Writer.WriteLine("[Runner executing:\t{0}]", message);
            Writer.WriteLine("[MonoTouch Version:\t{0}]", Constants.Version);
            Writer.WriteLine("[Assembly:\t{0}.dll ({1} bits)]", typeof(NSObject).Assembly.GetName().Name, IntPtr.Size * 8);
            Writer.WriteLine("[GC:\t{0}]", GC.MaxGeneration == 0 ? "Boehm": "sgen");
            WriteDeviceInformation(Writer);
            Writer.WriteLine("[Device Locale:\t{0}]", NSLocale.CurrentLocale.Identifier);
            Writer.WriteLine("[Device Date/Time:\t{0}]", now);              // to match earlier C.WL output

            Writer.WriteLine("[Bundle:\t{0}]", NSBundle.MainBundle.BundleIdentifier);
            // FIXME: add data about how the app was compiled (e.g. ARMvX, LLVM, GC and Linker options)
            PassedCount       = 0;
            IgnoredCount      = 0;
            FailedCount       = 0;
            InconclusiveCount = 0;
            return(true);
        }
示例#4
0
        public bool OpenWriter(string message)
        {
            TouchOptions options = TouchOptions.Current;
            DateTime     now     = DateTime.Now;

            // let the application provide it's own TextWriter to ease automation with AutoStart property
            if (Writer == null)
            {
                if (options.ShowUseNetworkLogger)
                {
                    var hostname = SelectHostName(options.HostName.Split(','), options.HostPort);

                    if (hostname != null)
                    {
                        Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                        try {
                            WriterFinishedTask = null;
                            switch (options.Transport)
                            {
                            case "HTTP":
                                var w = new HttpTextWriter()
                                {
                                    HostName = hostname,
                                    Port     = options.HostPort,
                                };
                                w.Open();
                                Writer             = w;
                                WriterFinishedTask = w.FinishedTask;
                                break;

                            default:
                                Console.WriteLine("Unknown transport '{0}': switching to default (TCP)", options.Transport);
                                goto case "TCP";

                            case "TCP":
                                Writer = new TcpTextWriter(hostname, options.HostPort);
                                break;
                            }
                        }
                        catch (Exception ex) {
#if __TVOS__ || __WATCHOS__
                            Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", hostname, options.HostPort, ex);
                            Writer = Console.Out;
#else
                            Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}.", hostname, options.HostPort, ex);
                            UIAlertView alert = new UIAlertView("Network Error",
                                                                String.Format("Cannot connect to {0}:{1}: {2}. Continue on console ?", hostname, options.HostPort, ex.Message),
                                                                null, "Cancel", "Continue");
                            int button = -1;
                            alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
                                button = (int)e.ButtonIndex;
                            };
                            alert.Show();
                            while (button == -1)
                            {
                                NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow(0.5));
                            }
                            Console.WriteLine(button);
                            Console.WriteLine("[Host unreachable: {0}]", button == 0 ? "Execution cancelled" : "Switching to console output");
                            if (button == 0)
                            {
                                return(false);
                            }
                            else
                            {
                                Writer = Console.Out;
                            }
#endif
                        }
                    }
                }
                else
                {
                    Writer = Console.Out;
                }
            }

            Writer.WriteLine("[Runner executing:\t{0}]", message);
            Writer.WriteLine("[MonoTouch Version:\t{0}]", Constants.Version);
            Writer.WriteLine("[Assembly:\t{0}.dll ({1} bits)]", typeof(NSObject).Assembly.GetName().Name, IntPtr.Size * 8);
            Writer.WriteLine("[GC:\t{0}]", GC.MaxGeneration == 0 ? "Boehm": "sgen");
            WriteDeviceInformation(Writer);
            Writer.WriteLine("[Device Locale:\t{0}]", NSLocale.CurrentLocale.Identifier);
            Writer.WriteLine("[Device Date/Time:\t{0}]", now);              // to match earlier C.WL output

            Writer.WriteLine("[Bundle:\t{0}]", NSBundle.MainBundle.BundleIdentifier);
            // FIXME: add data about how the app was compiled (e.g. ARMvX, LLVM, GC and Linker options)
            PassedCount       = 0;
            IgnoredCount      = 0;
            FailedCount       = 0;
            InconclusiveCount = 0;
            return(true);
        }