コード例 #1
0
        public UIViewController GetViewController()
        {
            var menu = new RootElement("Test Runner");

            Section main = new Section("Loading test suites...");

            menu.Add(main);

            Section options = new Section()
            {
                new StyledStringElement("Options", Options)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                },
                new StyledStringElement("Credits", Credits)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                }
            };

            menu.Add(options);

            // large unit tests applications can take more time to initialize
            // than what the iOS watchdog will allow them on devices, so loading
            // must be done async.

            // ensure that the dialog's view has been loaded so we can call Reload later
            var dialog = new DialogViewController(menu)
            {
                Autorotate = true
            };
            var dialogView = dialog.View;

            ThreadPool.QueueUserWorkItem((v) => {
                LoadSync();

                ExecuteOnMainThread(() =>
                {
                    foreach (TestSuite ts in Suite.Tests)
                    {
                        main.Add(Setup(ts));
                    }

                    main.Caption = null;
                    menu.Reload(main, UITableViewRowAnimation.Fade);

                    options.Insert(0, new StringElement("Run Everything", Run));
                    menu.Reload(options, UITableViewRowAnimation.Fade);

                    AutoRun();
                });
            });

            return(dialog);
        }
コード例 #2
0
        //------------------------------------------------------------------------------
        void UpdateJSON(RootElement rootElement, Element element)
        {
            var plugin = Settings.GetPlugin <IJSONSettingsPlugin>();

            var json = plugin.SaveSettingsToJSON();

            element.Caption = json;

            rootElement.Reload(element, UITableViewRowAnimation.Automatic);
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _hud = this.CreateHud();

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
                View.EndEditing(true);
                ViewModel.SaveCommand.Execute(null);
            });

            var title = new InputElement("Title", string.Empty, string.Empty)
            {
                TextAlignment = UITextAlignment.Right
            };

            title.Changed += (object sender, EventArgs e) => ViewModel.Title = title.Value;

            var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);

            assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            assignedTo.Tapped   += () => ViewModel.GoToAssigneeCommand.Execute(null);

            var kind = new StyledStringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1);

            kind.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            kind.Tapped   += () =>
            {
                var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind)
                {
                    Title = "Issue Type"
                };
                ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower();
                NavigationController.PushViewController(ctrl, true);
            };

            var priority = new StyledStringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1);

            priority.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            priority.Tapped   += () =>
            {
                var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority)
                {
                    Title = "Priority"
                };
                ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower();
                NavigationController.PushViewController(ctrl, true);
            };

            var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1);

            milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            milestone.Tapped   += () => ViewModel.GoToMilestonesCommand.Execute(null);

            var component = new StyledStringElement("Component".t(), "None", UITableViewCellStyle.Value1);

            component.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            component.Tapped   += () => ViewModel.GoToComponentsCommand.Execute(null);

            var version = new StyledStringElement("Version".t(), "None", UITableViewCellStyle.Value1);

            version.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            version.Tapped   += () => ViewModel.GoToVersionsCommand.Execute(null);

            var content = new MultilinedElement("Description");

            content.Tapped += () =>
            {
                var composer = new Composer {
                    Title = "Issue Description", Text = content.Value
                };
                composer.NewComment(this, (text) => {
                    ViewModel.Content = text;
                    composer.CloseComposer();
                });
            };

            ViewModel.Bind(x => x.IsSaving, x =>
            {
                if (x)
                {
                    _hud.Show("Saving...");
                }
                else
                {
                    _hud.Hide();
                }
            });

            Root = new RootElement(Title)
            {
                new Section {
                    title, assignedTo, kind, priority
                }, new Section {
                    milestone, component, version
                }, new Section {
                    content
                }
            };

            ViewModel.Bind(x => x.Title, x => {
                title.Value = x;
                Root.Reload(title, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.AssignedTo, x => {
                assignedTo.Value = x == null ? "Unassigned" : x.Username;
                Root.Reload(assignedTo, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Kind, x => {
                kind.Value = x;
                Root.Reload(kind, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Priority, x => {
                priority.Value = x;
                Root.Reload(priority, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Milestone, x => {
                milestone.Value = x ?? "None";
                Root.Reload(milestone, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Component, x => {
                component.Value = x ?? "None";
                Root.Reload(component, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Version, x => {
                version.Value = x ?? "None";
                Root.Reload(version, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Content, x => {
                content.Value = x;
                Root.Reload(content, UITableViewRowAnimation.None);
            }, true);
        }
コード例 #4
0
        public UIViewController GetViewController()
        {
            var menu = new RootElement("Test Runner");

            Section main = new Section("Loading test suites...");

            menu.Add(main);

            Section options = new Section()
            {
                new StyledStringElement("Options", Options)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                },
                new StyledStringElement("Credits", Credits)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                }
            };

            menu.Add(options);

            // large unit tests applications can take more time to initialize
            // than what the iOS watchdog will allow them on devices
            ThreadPool.QueueUserWorkItem(delegate {
                foreach (Assembly assembly in assemblies)
                {
                    Load(assembly, null);
                }

                window.InvokeOnMainThread(delegate {
                    foreach (TestSuite ts in suite.Tests)
                    {
                        main.Add(Setup(ts));
                    }
                    mre.Set();

                    main.Caption = null;
                    menu.Reload(main, UITableViewRowAnimation.Fade);

                    options.Insert(0, new StringElement("Run Everything", Run));
                    menu.Reload(options, UITableViewRowAnimation.Fade);
                });
                assemblies.Clear();
            });

            var dv = new DialogViewController(menu)
            {
                Autorotate = true
            };

            // AutoStart running the tests (with either the supplied 'writer' or the options)
            if (AutoStart)
            {
                ThreadPool.QueueUserWorkItem(delegate {
                    mre.WaitOne();
                    window.BeginInvokeOnMainThread(delegate {
                        Run();
                        // optionally end the process, e.g. click "Touch.Unit" -> log tests results, return to springboard...
                        // http://stackoverflow.com/questions/1978695/uiapplication-sharedapplication-terminatewithsuccess-is-not-there
                        if (TerminateAfterExecution)
                        {
                            TerminateWithSuccess();
                        }
                    });
                });
            }
            return(dv);
        }
コード例 #5
0
 //------------------------------------------------------------------------------
 void UpdateJSON(RootElement rootElement, MultilineElement element)
 {
     element.Caption = AssemblyClass.GetJSON();
     rootElement.Reload(element, UITableViewRowAnimation.Automatic);
 }
コード例 #6
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			_hud = this.CreateHud();

			NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
				View.EndEditing(true);
				ViewModel.SaveCommand.Execute(null);
			});

			var title = new InputElement("Title", string.Empty, string.Empty) { TextAlignment = UITextAlignment.Right };
			title.Changed += (object sender, EventArgs e) => ViewModel.Title = title.Value;

			var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
			assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			assignedTo.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null);

			var kind = new StyledStringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1);
			kind.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			kind.Tapped += () =>
			{
				var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind) { Title = "Issue Type" };
				ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower();
				NavigationController.PushViewController(ctrl, true);
			};

			var priority = new StyledStringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1);
			priority.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			priority.Tapped += () => 
			{
				var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority) { Title = "Priority" };
				ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower();
				NavigationController.PushViewController(ctrl, true);
			};

			var milestone = new StyledStringElement("Milestone", "None", UITableViewCellStyle.Value1);
			milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			milestone.Tapped += () => ViewModel.GoToMilestonesCommand.Execute(null);

			var component = new StyledStringElement("Component", "None", UITableViewCellStyle.Value1);
			component.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            component.Tapped += () => ViewModel.GoToComponentsCommand.Execute(null);

			var version = new StyledStringElement("Version", "None", UITableViewCellStyle.Value1);
			version.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            version.Tapped += () => ViewModel.GoToVersionsCommand.Execute(null);

			var content = new MultilinedElement("Description");
			content.Tapped += () =>
			{
                var composer = new Composer { Title = "Issue Description", Text = content.Value };
				composer.NewComment(this, (text) => {
					ViewModel.Content = text;
					composer.CloseComposer();
				});
			};

			ViewModel.Bind(x => x.IsSaving, x =>
			{
				if (x)
					_hud.Show("Saving...");
				else
					_hud.Hide();
			});

			Root = new RootElement(Title) { new Section { title, assignedTo, kind, priority }, new Section { milestone, component, version }, new Section { content } };

			ViewModel.Bind(x => x.Title, x => {
				title.Value = x;
				Root.Reload(title, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.AssignedTo, x => {
				assignedTo.Value = x == null ? "Unassigned" : x.Username;
				Root.Reload(assignedTo, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Kind, x => {
				kind.Value = x;
				Root.Reload(kind, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Priority, x => {
				priority.Value = x;
				Root.Reload(priority, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Milestone, x => {
				milestone.Value = x ?? "None";
				Root.Reload(milestone, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Component, x => {
				component.Value = x ?? "None";
				Root.Reload(component, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Version, x => {
				version.Value = x ?? "None";
				Root.Reload(version, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Content, x => {
				content.Value = x;
				Root.Reload(content, UITableViewRowAnimation.None);
			}, true);
		}