Inheritance: MonoBehaviour
Beispiel #1
0
 public void BeforeEach()
 {
     _viewModel = new TestViewModel();
     _command   = new TestCommand(_viewModel);
     _button    = new TestButton();
     _binder    = Create.Binder(_viewModel);
 }
    public void addContent(List <string> list, int testId)
    {
        index = testId;
        int i = 0;

        foreach (string str in list)
        {
            GameObject go;
            if (i == 0)
            {
                go = Button_Template;
            }
            else
            {
                go = Instantiate(Button_Template) as GameObject;
            }
            go.SetActive(true);
            TestButton TB = go.GetComponent <TestButton>();
            TB.SetName(str);
            TB.SetIndex(index);
            TB.SetQNum(i + 1);
            go.transform.SetParent(Button_Template.transform.parent);
            i++;
        }
        index++;
    }
    /* Unity old UI
     *  public void OnPointerClick(PointerEventData data){
     *  // if clicked at button
     *  // if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() != null)
     *  if(gameObject.tag == "b"){
     *      Application.LoadLevel("New_Menu");
     *  }
     * }
     */

    // FOR the BUTTON SYSTEM
    private void OnButtonPressed(TestButton data)
    {
        // if clicked at button
        // if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() != null)

        SceneManager.LoadScene("New_Menu");
    }
Beispiel #4
0
        void ReleaseDesignerOutlets()
        {
            if (ResponseLabel != null)
            {
                ResponseLabel.Dispose();
                ResponseLabel = null;
            }

            if (ResultTextView != null)
            {
                ResultTextView.Dispose();
                ResultTextView = null;
            }

            if (TestButton != null)
            {
                TestButton.Dispose();
                TestButton = null;
            }

            if (TestPostButton != null)
            {
                TestPostButton.Dispose();
                TestPostButton = null;
            }
        }
    /* FOR UNITY's UI
     * public void OnPointerClick(PointerEventData data){
     * MeshRenderer[] objects = molecule.GetComponentsInChildren<MeshRenderer>();
     * if(ON_OFF_Button.GetComponentsInChildren<Text>()[0].text == "Polyhedral OFF"){ // plates are on
     *     foreach (MeshRenderer i in objects){
     *         if(i.gameObject.ToString().Contains(keyword))
     *             // hide paltes
     *             i.enabled = false;
     *     }
     *     ON_OFF_Button.GetComponentsInChildren<Text>()[0].text = "Polyhedral ON";
     * }
     * else if(ON_OFF_Button.GetComponentsInChildren<Text>()[0].text == "Polyhedral ON"){
     *     foreach (MeshRenderer i in objects){
     *         if(i.gameObject.ToString().Contains(keyword))
     *             // show plates
     *             i.enabled = true;
     *     }
     *     ON_OFF_Button.GetComponentsInChildren<Text>()[0].text = "Polyhedral OFF";
     * }
     * }
     */

    // FOR the BUTTON SYSTEM
    private void OnButtonPressed(TestButton data)
    {
        MeshRenderer[] objects = molecule.GetComponentsInChildren <MeshRenderer>();
        if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Polyhedral OFF")
        { // plates are on
            foreach (MeshRenderer i in objects)
            {
                if (i.gameObject.ToString().Contains(keyword))
                {
                    // hide paltes
                    i.enabled = false;
                }
            }
            ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Polyhedral ON";
        }
        else if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Polyhedral ON")
        {
            foreach (MeshRenderer i in objects)
            {
                if (i.gameObject.ToString().Contains(keyword))
                {
                    // show plates
                    i.enabled = true;
                }
            }
            ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Polyhedral OFF";
        }
    }
Beispiel #6
0
        public void Should_TurnOff_IfButtonPressed_WhileTargetIsAlreadyOn()
        {
            var timer = new TestHomeAutomationTimer();

            timer.SetTime(TimeSpan.Parse("14:00:00"));

            var automation = new TurnOnAndOffAutomation(AutomationIdFactory.EmptyId, timer, new TestHttpRequestController(), new TestLogger());
            var button     = new TestButton();

            var output = new TestBinaryStateOutputActuator();

            output.State.ShouldBeEquivalentTo(BinaryActuatorState.Off);

            automation.WithTrigger(button.GetPressedShortlyTrigger());
            automation.WithTarget(output);

            IBinaryStateOutputActuator[] otherActuators =
            {
                new TestBinaryStateOutputActuator().WithOffState(), new TestBinaryStateOutputActuator().WithOffState()
            };

            automation.WithSkipIfAnyActuatorIsAlreadyOn(otherActuators);

            button.PressShort();
            output.State.ShouldBeEquivalentTo(BinaryActuatorState.On);

            button.PressShort();
            output.State.ShouldBeEquivalentTo(BinaryActuatorState.On);

            automation.WithTurnOffIfButtonPressedWhileAlreadyOn();
            button.PressShort();
            output.State.ShouldBeEquivalentTo(BinaryActuatorState.Off);
        }
Beispiel #7
0
        public void Button_Raises_Click()
        {
            var           mouse    = Mock.Of <IMouseDevice>();
            var           renderer = Mock.Of <IRenderer>();
            IInputElement captured = null;

            Mock.Get(mouse).Setup(m => m.GetPosition(It.IsAny <IVisual>())).Returns(new Point(50, 50));
            Mock.Get(mouse).Setup(m => m.Capture(It.IsAny <IInputElement>())).Callback <IInputElement>(v => captured = v);
            Mock.Get(mouse).Setup(m => m.Captured).Returns(() => captured);
            Mock.Get(renderer).Setup(r => r.HitTest(It.IsAny <Point>(), It.IsAny <IVisual>(), It.IsAny <Func <IVisual, bool> >()))
            .Returns <Point, IVisual, Func <IVisual, bool> >((p, r, f) =>
                                                             r.Bounds.Contains(p) ? new IVisual[] { r } : new IVisual[0]);

            var target = new TestButton()
            {
                Bounds   = new Rect(0, 0, 100, 100),
                Renderer = renderer
            };

            bool clicked = false;

            target.Click += (s, e) => clicked = true;

            RaisePointerEnter(target, mouse);
            RaisePointerMove(target, mouse);
            RaisePointerPressed(target, mouse, 1, MouseButton.Left);

            Assert.Equal(captured, target);

            RaisePointerReleased(target, mouse, MouseButton.Left);

            Assert.Equal(captured, null);

            Assert.True(clicked);
        }
Beispiel #8
0
        public void Button_Does_Not_Raise_Click_When_PointerReleased_Outside()
        {
            var renderer = Mock.Of <IRenderer>();

            Mock.Get(renderer).Setup(r => r.HitTest(It.IsAny <Point>(), It.IsAny <IVisual>(), It.IsAny <Func <IVisual, bool> >()))
            .Returns <Point, IVisual, Func <IVisual, bool> >((p, r, f) =>
                                                             r.Bounds.Contains(p) ? new IVisual[] { r } : new IVisual[0]);

            var target = new TestButton()
            {
                Bounds   = new Rect(0, 0, 100, 100),
                Renderer = renderer
            };

            bool clicked = false;

            target.Click += (s, e) => clicked = true;

            RaisePointerEnter(target);
            RaisePointerMove(target, new Point(50, 50));
            RaisePointerPressed(target, 1, MouseButton.Left, new Point(50, 50));
            RaisePointerLeave(target);

            Assert.Equal(_helper.Captured, target);

            RaisePointerReleased(target, MouseButton.Left, new Point(200, 50));

            Assert.Equal(_helper.Captured, null);

            Assert.False(clicked);
        }
Beispiel #9
0
    // Use this for initialization
    void Start () {
        if (!buttonPrefab) {
            Debug.LogError("Help! No button prefab found!");
        }

        foreach (Transform child in gameObject.transform) {
            Destroy(child.gameObject);
        }

        foreach (string key in Fitboard.FitboardKeys) {
            GameObject newButton = Instantiate(buttonPrefab) as GameObject;
            newButton.transform.SetParent(gameObject.transform);
            ConfigButton CB = newButton.GetComponent<ConfigButton>();
            TestButton TB = newButton.GetComponent<TestButton>();
            if (CB) {
                Text txt = CB.GetComponentInChildren<Text>();
                txt.text = key;
                CB.keyID = key;
                newButton.name = key;
            } else if (TB) {
                Text txt = TB.GetComponentInChildren<Text>();
                txt.text = key;
                TB.keyID = key;
                newButton.name = key;
            } else {
                Debug.LogError("Uh oh! This button prefab: " + buttonPrefab + "doesn't have a config or test script");
            }
        }

	}
Beispiel #10
0
 private void OberflächeDeaktivieren(bool Aktivieren)
 {
     if (Aktivieren)
     {
         CSVPfadSuchenButton.Invoke(new Action <bool>(s => { CSVPfadSuchenButton.Enabled = s; }), true);
         TestEmailAdresseTextBox.Invoke(new Action <bool>(s => { TestEmailAdresseTextBox.Enabled = s; }), true);
         if (AdressePrüfen(TestEmailAdresseTextBox.Text))
         {
             TestButton.Invoke(new Action <bool>(s => { TestButton.Enabled = s; }), true);
         }
         StartenButton.Invoke(new Action <bool>(s => { StartenButton.Enabled = s; }), true);
         StatusLabel.Invoke(new Action <string>(s => { StatusLabel.Text = s; }), "Status: 0/0 versendet ETA: 0m 0s");
         Ladebalken.Invoke(new Action <int>(s => { Ladebalken.Minimum = s; }), 0);
         if (!ReferenceEquals(AlleMails, null))
         {
             Ladebalken.Invoke(new Action <int>(s => { Ladebalken.Maximum = s; }), AlleMails.Length);
         }
         else
         {
             Ladebalken.Invoke(new Action <int>(s => { Ladebalken.Maximum = s; }), 1);
         }
         Ladebalken.Invoke(new Action <int>(s => { Ladebalken.Value = s; }), 0);
     }
     else
     {
         CSVPfadSuchenButton.Invoke(new Action <bool>(s => { CSVPfadSuchenButton.Enabled = s; }), false);
         TestEmailAdresseTextBox.Invoke(new Action <bool>(s => { TestEmailAdresseTextBox.Enabled = s; }), false);
         TestButton.Invoke(new Action <bool>(s => { TestButton.Enabled = s; }), false);
         StartenButton.Invoke(new Action <bool>(s => { StartenButton.Enabled = s; }), false);
     }
 }
Beispiel #11
0
        public void DisposeDeregistersButtonClickedEvent()
        {
            var button = new TestButton();
            var obj    = new Binding.Gtk.BindButtonToCommand(button);

            obj.Dispose();

            Assert.IsTrue(button.ClickedEventWasRemoved);
        }
        static void DelegateEventsExample()
        {
            TestButton tb = new TestButton();

            tb.button1.ClickEvent += Button1_ClickEvent;
            tb.button1.ClickEvent += TestEventFunction;
            tb.RegisterFunction();
            tb.RegisterFunction();
            tb.button1.Call();
        }
Beispiel #13
0
    /* Unity old UI
     *  public void OnPointerClick(PointerEventData data){
     *  // if clicked at button
     *  // if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() != null)
     *  if(gameObject.tag == "b"){
     #if UNITY_EDITOR
     *   UnityEditor.EditorApplication.isPlaying = false;
     #else
     *   Application.Quit();
     #endif
     *  }
     * }
     */

    //with buttons
    private void OnButtonPressed(TestButton data)
    {
        // if clicked at button
        // if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() != null)
        #if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false;
        #else
        Application.Quit();
        #endif
    }
Beispiel #14
0
        private void OnButtonPressed(TestButton source)
        {
            ButtonActionResponse buttonActionResponse;

            buttonActionResponse = ButtonActionsResponse[0];
            buttonActionResponse.Response.Invoke();


            button.Selected = false;
        }
    /* FOR UNITY's UI
     *  public void OnPointerClick(PointerEventData data) {
     *          // GvrControllerInput.AppButton
     *          if(ON_OFF_Button.GetComponentsInChildren<Text>()[0].text == "Movement Mode ON"){ // not able to move
     *                  // remove old Sphere Collider
     *                  MeshRenderer[] objects = molecule.GetComponentsInChildren<MeshRenderer>();
     *                  foreach (MeshRenderer i in objects){
     *                          GameObject atom = i.gameObject;
     *                          Destroy(atom.GetComponent<SphereCollider>());
     *                  }
     *      // add grabbable script
     *
     *      //molecule.AddComponent<InputTest>();
     *
     *
     *      // add Sphere Collider
     *      molecule.AddComponent<GrabbableSimple>();
     *                  SphereCollider collider_molecule = molecule.AddComponent<SphereCollider>() as SphereCollider;
     *          collider_molecule.radius = 10;
     *                  ON_OFF_Button.GetComponentsInChildren<Text>()[0].text = "Movement Mode OFF";
     *      molecule.AddComponent<HandDraggable>();
     *      molecule.AddComponent<RotatableObject>();
     *  }
     *          else if(ON_OFF_Button.GetComponentsInChildren<Text>()[0].text == "Movement Mode OFF"){
     *      Destroy(GetComponent<GrabbableSimple>());
     *      // remove old Sphere Collider
     *      Destroy(molecule.GetComponent<SphereCollider>());
     *      Destroy(molecule.GetComponent<HandDraggable>());
     *      Destroy(molecule.GetComponent<RotatableObject>());
     *      // add Sphere Collider
     *      MeshRenderer[] objects = molecule.GetComponentsInChildren<MeshRenderer>();
     *                  foreach (MeshRenderer i in objects){
     *                          GameObject atom = i.gameObject;
     *          if (atom.ToString().Contains(keyword)){
     *                                  SphereCollider collider_atom = atom.AddComponent<SphereCollider>() as SphereCollider;
     *                          }
     *                  }
     *                  ON_OFF_Button.GetComponentsInChildren<Text>()[0].text = "Movement Mode ON";
     *
     *  }
     * }
     */

    // FOR the BUTTON SYSTEM
    private void OnButtonPressed(TestButton data)
    {
        // GvrControllerInput.AppButton
        if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Movement Mode ON")
        { // not able to move
          // remove old Sphere Collider
            Debug.Log("1");
            List <GameObject> l = new List <Transform>(molecule.transform.GetComponentsInChildren <Transform>()).ConvertAll <GameObject>(delegate(Transform p_it) { return(p_it.gameObject); });
            foreach (GameObject i in l)
            {
                GameObject atom = i.gameObject;
                Destroy(atom.GetComponent <SphereCollider>());
            }
            Debug.Log("2");
            // add grabbable script

            //molecule.AddComponent<InputTest>();


            // add Sphere Collider
            molecule.AddComponent <GrabbableSimple>();
            Debug.Log("3");
            SphereCollider collider_molecule = molecule.AddComponent <SphereCollider>() as SphereCollider;
            if (molecule.name == "sucrose_soft" || molecule.name == "ethane(Clone)" || molecule.name == "Ethanol(Clone)" || molecule.name == "ethene(Clone)" || molecule.name == "methane(Clone)" || molecule.name == "Polyethylene(Clone)" || molecule.name == "propane(Clone)" || molecule.name == "sucrose(Clone)" || molecule.name == "water(Clone)" || molecule.name == "Sulfuric Acid(Clone)")
            {
                collider_molecule.radius = 3;
            }
            else
            {
                collider_molecule.radius = 9;
            }
            ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Movement Mode OFF";
            molecule.AddComponent <HandDraggable>();
            molecule.AddComponent <RotatableObject>();
        }
        else if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Movement Mode OFF")
        {
            Destroy(GetComponent <GrabbableSimple>());
            // remove old Sphere Collider
            Destroy(molecule.GetComponent <SphereCollider>());
            Destroy(molecule.GetComponent <HandDraggable>());
            Destroy(molecule.GetComponent <RotatableObject>());
            // add Sphere Collider
            List <GameObject> l = new List <Transform>(molecule.transform.GetComponentsInChildren <Transform>()).ConvertAll <GameObject>(delegate(Transform p_it) { return(p_it.gameObject); });
            foreach (GameObject i in l)
            {
                GameObject atom = i.gameObject;
                if (atom.ToString().Contains(keyword))
                {
                    SphereCollider collider_atom = atom.AddComponent <SphereCollider>() as SphereCollider;
                }
            }
            ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Movement Mode ON";
        }
    }
Beispiel #16
0
 // FOR the BUTTON SYSTEM
 private void OnButtonPressed(TestButton data)
 {
     if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Electron Density OFF")
     {
         Electron_Density.SetActive(false);
         ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Electron Density ON";
     }
     else if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Electron Density ON")
     {
         Electron_Density.SetActive(true);
         ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Electron Density OFF";
     }
 }
    /* FOR UNITY'S UI SYSTEM
     *  public void OnPointerClick(PointerEventData data) {
     *          if(ON_OFF_Button.GetComponentsInChildren<Text>()[0].text == "Rotation Mode OFF"){ // rotating
     *                  objMessage.pause();
     *                  ON_OFF_Button.GetComponentsInChildren<Text>()[0].text = "Rotation Mode ON";
     *          }
     *          else if(ON_OFF_Button.GetComponentsInChildren<Text>()[0].text == "Rotation Mode ON"){
     *                  objMessage.revolve();
     *                  ON_OFF_Button.GetComponentsInChildren<Text>()[0].text = "Rotation Mode OFF";
     *          }
     *  }
     */

    // FOR the BUTTON SYSTEM
    private void OnButtonPressed(TestButton data)
    {
        if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Rotation Mode OFF")
        { // rotating
            objMessage.pause();
            ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Rotation Mode ON";
        }
        else if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Rotation Mode ON")
        {
            objMessage.revolve();
            ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Rotation Mode OFF";
        }
    }
        public void ContainerTest()
        {
            TestButton control = new TestButton();

            _helper.IDesignerHost.Container.Add(control, "SomeName");
            Assert.AreEqual("SomeName", control.Site.Name, "#1");
            Assert.IsNotNull(_helper.IDesignerHost.GetDesigner(control), "#2");
            Assert.AreEqual(control, _helper.IDesignerHost.Container.Components["SomeName"], "#3");

            _helper.IDesignerHost.Container.Remove(control);
            Assert.IsNull(_helper.IDesignerHost.GetDesigner(control), "#4");
            Assert.IsNull(_helper.IDesignerHost.Container.Components["SomeName"], "#5");
        }
    public void addContent(string s, int testId, int q)
    {
        GameObject go = Instantiate(Button_Template) as GameObject;

        go.SetActive(true);
        TestButton TB = go.GetComponent <TestButton>();

        TB.SetName(s);
        TB.SetIndex(testId);
        TB.SetQNum(q);
        go.transform.SetParent(Button_Template.transform.parent);
        index = testId + 1;
    }
Beispiel #20
0
        public void ApplyTemplateTest()
        {
            Button b = new Button();

            Assert.AreEqual(0, VisualTreeHelper.GetChildrenCount(b), "1");

            b.ApplyTemplate();

            Assert.AreEqual(0, VisualTreeHelper.GetChildrenCount(b), "2");

            TestButton tb = new TestButton();

            Assert.IsFalse(tb.NameFound, "3");
        }
Beispiel #21
0
            public StarSizingWithMinimumMaximumMeasureGrid()
            {
                ColumnDefinition c = new ColumnDefinition();

                c.MinWidth = 100;
                ColumnDefinitions.Add(c);
                ColumnDefinitions.Add(new ColumnDefinition());
                TestButton b = new TestButton();

                Children.Add(b);
                Grid.SetColumn(b, 1);
                Measure(new Size(150, 100));
                Assert.AreEqual(measure_constraint.Width, 50);
            }
        void ReleaseDesignerOutlets()
        {
            if (TestText != null)
            {
                TestText.Dispose();
                TestText = null;
            }

            if (TestButton != null)
            {
                TestButton.Dispose();
                TestButton = null;
            }
        }
Beispiel #23
0
        public void RegisteringCallsLoaded()
        {
            TestButton b      = new TestButton();
            bool       loaded = false;

            b.Loaded += delegate { loaded = true; };

            HtmlPage.RegisterScriptableObject("testButton", b);

            Assert.IsFalse(loaded, "1");

            b.ApplyTemplate();

            Assert.IsFalse(b.OnApplyTemplateCalled, "2");
        }
			public MeasureStackPanel ()
			{
				Size result = MeasureOverride (new Size (double.PositiveInfinity, double.PositiveInfinity));
				Assert.AreEqual (result.Width, 0, "1");
				Assert.AreEqual (result.Height, 0, "2");
				TestButton button = new TestButton ();
				Children.Add (button);
				result = MeasureOverride (new Size (double.PositiveInfinity, double.PositiveInfinity));
				Assert.AreEqual (result.Width, Utility.GetEmptyButtonSize (), "3");
				Assert.AreEqual (result.Height, Utility.GetEmptyButtonSize (), "4");
				Assert.IsTrue (called, "5");
				called = false;
				Assert.IsTrue (double.IsPositiveInfinity (measure_constraint.Width), "6");
				Assert.IsTrue (double.IsPositiveInfinity (measure_constraint.Height), "7");
			}
Beispiel #25
0
        public void Should_TurnOn_IfButtonPressedShort()
        {
            var automation = new TurnOnAndOffAutomation(AutomationIdFactory.EmptyId, new TestHomeAutomationTimer(), new TestHttpRequestController(), new TestLogger());
            var button     = new TestButton();
            var output     = new TestBinaryStateOutputActuator();

            output.State.ShouldBeEquivalentTo(BinaryActuatorState.Off);

            automation.WithTrigger(button.GetPressedShortlyTrigger());
            automation.WithTarget(output);

            button.PressShort();

            output.State.ShouldBeEquivalentTo(BinaryActuatorState.On);
        }
Beispiel #26
0
            /// <summary>
            /// Instantiates the relevant keys based on the version and button prefab. Forces a layout rebuild.
            /// </summary>
            private void instantiateKeys()
            {
                settingsButtons.Clear();
                foreach (string key in keyList)
                {
                    // Instantiates new button
                    // Handles reloading current config (in Start of buttons)
                    GameObject newButton = Instantiate(buttonPrefab) as GameObject;
                    newButton.transform.SetParent(gameObject.transform, false);
                    ConfigButton   CB = newButton.GetComponent <ConfigButton>();
                    SettingsButton SB = newButton.GetComponent <SettingsButton>();
                    TestButton     TB = newButton.GetComponent <TestButton>();
                    if (key == "")
                    {
                        CB.setInactive();
                    }
                    else
                    {
                        if (SB)
                        {
                            Debug.Log("loading settings buttons");
                            if (FitBoardSave.hasConfig)
                            {
                                Debug.Log("Houston, we have a config");
                                int toggle = ConfigUtils.getConfigToggle(key);
                                SB.setButton(key, ConfigUtils.getToggleColor(toggle), true, toggle);
                                settingsButtons.Add(SB);
                            }
                            else
                            {
                                Debug.Log("loading default config");
                                SB.setButton(key, Color.grey, true);
                                settingsButtons.Add(SB);
                            }
                        }
                        else if (TB)
                        {
                            TB.setButton(key, Color.grey, true);
                        }
                        else
                        {
                            Debug.LogError("Uh oh! This button prefab: " + buttonPrefab + "doesn't have a config or test script");
                        }
                    }
                }

                LayoutRebuilder.ForceRebuildLayoutImmediate(layout);
            }
Beispiel #27
0
            public StarSizingMeasureGrid()
            {
                ColumnDefinition c = new ColumnDefinition();

                c.Width = GridLength.Auto;
                ColumnDefinitions.Add(c);
                ColumnDefinitions.Add(new ColumnDefinition());
                TestButton b = new TestButton();

                Children.Add(b);
                Children.Add(new TestButton2());
                Grid.SetColumn(b, 1);
                Measure(new Size(100, 100));
                Assert.AreEqual(measure_constraint.Width, 100 - Utility.GetEmptyButtonSize(), "1");
                Assert.AreEqual(calls, 1, "2");
            }
Beispiel #28
0
            public MeasureConstraintGrid()
            {
                RowDefinitions.Add(new RowDefinition());
                RowDefinition row_definition = new RowDefinition();

                row_definition.Height = new GridLength(1, GridUnitType.Star);
                RowDefinitions.Add(row_definition);
                TestButton button = new TestButton();

                Children.Add(button);
                Window window = new Window();

                window.Content = this;
                window.Show();
                Assert.AreEqual(measure_constraint.Width, ActualWidth);
            }
Beispiel #29
0
    public void SelectShouldHoldThePreviousStateAfterDisablingAndEnabling()
    {
        TestButton button = m_PrefabRoot.GetComponentInChildren <TestButton>();

        button.onClick.AddListener(() => {
            button.Select();
            button.enabled = false;
        });
        button.OnPointerClick(new PointerEventData(m_PrefabRoot.GetComponentInChildren <EventSystem>())
        {
            button = PointerEventData.InputButton.Left
        });
        Assert.False(button.enabled, "Expected button to not be enabled");
        button.enabled = true;
        Assert.True(button.isStateSelected, "Expected selected state to be true");
    }
Beispiel #30
0
            public MeasureOrderGrid()
            {
                Children.Add(new TestButton(0));
                TestButton b2 = new TestButton(1);

                SetRow(b2, 1);
                Children.Add(b2);
                TestButton b3 = new TestButton(2);

                SetColumn(b3, 1);
                Children.Add(b3);
                Window w = new Window();

                w.Content = this;
                w.Show();
            }
Beispiel #31
0
    void CompositionTarget_Rendering(object sender, EventArgs e)
    {
        if (lastRenderTime == ((RenderingEventArgs)e).RenderingTime)
        {
            return;
        }

        lastRenderTime = ((RenderingEventArgs)e).RenderingTime;

        GeneralTransform2DTo3D transform = TestButton.TransformToAncestor(Container);
        Point3D point = transform.Transform(new Point(0, 0));

        cube_translation.OffsetX = point.X;
        cube_translation.OffsetY = point.Y;
        cube_translation.OffsetZ = point.Z;
    }
        public async Task EventSenderTestCore(bool addControlFirst, bool linearLayout) {
            Grid rootRoot = new Grid();
            Grid root = new Grid();
            Button bt = null;
            if(addControlFirst) {
                if(linearLayout) {
                    bt = new TestButton() { Name = "bt" };
                    root.Children.Add(bt);
                } else {
                    bt = new TestButton() { Name = "bt" };
                    rootRoot.Children.Add(bt);
                    rootRoot.Children.Add(root);
                }
            }

            EventToCommandTestClass eventToCommand1 = new EventToCommandTestClass() { EventName = "SizeChanged" };
            EventToCommandTestClass eventToCommand2 = new EventToCommandTestClass() { EventName = "SizeChanged" };
            BindingOperations.SetBinding(eventToCommand2, EventToCommand.SourceObjectProperty, new Binding() { ElementName = "bt" });
            EventToCommandTestClass eventToCommand3 = new EventToCommandTestClass() { EventName = "SizeChanged", SourceName = "bt" };

            EventToCommandTestClass eventToCommand4 = new EventToCommandTestClass() { EventName = "Loaded" };
            EventToCommandTestClass eventToCommand5 = new EventToCommandTestClass() { EventName = "Loaded" };
            BindingOperations.SetBinding(eventToCommand5, EventToCommand.SourceObjectProperty, new Binding() { ElementName = "bt" });
            EventToCommandTestClass eventToCommand6 = new EventToCommandTestClass() { EventName = "Loaded", SourceName = "bt" };

            Interaction.GetBehaviors(root).Add(eventToCommand1);
            Interaction.GetBehaviors(root).Add(eventToCommand2);
            Interaction.GetBehaviors(root).Add(eventToCommand3);
            Interaction.GetBehaviors(root).Add(eventToCommand4);
            Interaction.GetBehaviors(root).Add(eventToCommand5);
            Interaction.GetBehaviors(root).Add(eventToCommand6);

            if(!addControlFirst) {
                if(linearLayout) {
                    bt = new TestButton() { Name = "bt" };
                    root.Children.Add(bt);
                } else {
                    bt = new TestButton() { Name = "bt" };
                    rootRoot.Children.Add(bt);
                    rootRoot.Children.Add(root);
                }
            }
            bt.Loaded += bt_Loaded;
            bt.SizeChanged += bt_SizeChanged;
            if(linearLayout)
                Window.Content = root;
            else
                Window.Content = rootRoot;
            await EnqueueShowWindow();
            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
                Assert.AreEqual(1, eventToCommand1.EventCount);
                Assert.AreEqual(root, eventToCommand1.EventSender);
                Assert.AreEqual(EventToCommandType.AssociatedObject, eventToCommand1.Type);

                Assert.IsTrue(eventToCommand2.EventCount > 0);
                Assert.AreEqual(bt, eventToCommand2.EventSender);
                Assert.AreEqual(EventToCommandType.SourceObject, eventToCommand2.Type);

                Assert.AreEqual(1, eventToCommand3.EventCount);
                Assert.AreEqual(bt, eventToCommand3.EventSender);
                Assert.AreEqual(EventToCommandType.SourceName, eventToCommand3.Type);

                Assert.AreEqual(1, eventToCommand4.EventCount);
                Assert.AreEqual(root, eventToCommand4.EventSender);
                Assert.AreEqual(EventToCommandType.AssociatedObject, eventToCommand4.Type);

                Assert.AreEqual(1, eventToCommand5.EventCount);
                Assert.AreEqual(bt, eventToCommand5.EventSender);
                Assert.AreEqual(EventToCommandType.SourceObject, eventToCommand5.Type);

                Assert.AreEqual(1, eventToCommand6.EventCount);
                Assert.AreEqual(bt, eventToCommand6.EventSender);
                Assert.AreEqual(EventToCommandType.SourceName, eventToCommand6.Type);
            });
            EnqueueTestComplete();
        }
 public void NoExtraBindingUpdates()
 {
     using(var button = new TestButton()) {
         button.SetDataContext("test");
         button.SetBinding("Text2", new Binding());
         Assert.That(button.Text2SetCount, Is.EqualTo(1));
         button.SetDataContext("test");
         Assert.That(button.Text2SetCount, Is.EqualTo(1));
     }
 }
        public void SetBindingTwice()
        {
            using(var button = new TestButton()) {
                button.SetDataContext("test");
                button.SetBinding("Text2", new Binding());
                button.SetBinding("Text2", new Binding());
                Assert.That(button.Text2, Is.EqualTo("test"));
                Assert.That(button.Text2SetCount, Is.EqualTo(1));

                button.SetDataContext("test2");
                Assert.That(button.Text2, Is.EqualTo("test2"));
                Assert.That(button.Text2SetCount, Is.EqualTo(2));
            }
        }
Beispiel #35
0
		public void RegisteringCallsLoaded ()
		{
			TestButton b = new TestButton ();
			bool loaded = false;

			b.Loaded += delegate { loaded = true; };

			HtmlPage.RegisterScriptableObject("testButton", b);

			Assert.IsFalse (loaded, "1");

			b.ApplyTemplate ();

			Assert.IsFalse (b.OnApplyTemplateCalled, "2");
		}
		public void ContainerTest ()
		{
			TestButton control = new TestButton ();
			_helper.IDesignerHost.Container.Add (control, "SomeName");
			Assert.AreEqual ("SomeName", control.Site.Name, "#1");
			Assert.IsNotNull (_helper.IDesignerHost.GetDesigner (control), "#2");
			Assert.AreEqual (control, _helper.IDesignerHost.Container.Components["SomeName"], "#3");

			_helper.IDesignerHost.Container.Remove (control);
			Assert.IsNull (_helper.IDesignerHost.GetDesigner (control), "#4");
			Assert.IsNull (_helper.IDesignerHost.Container.Components["SomeName"], "#5");
		}
		public void NestedContainerTest ()
		{
			Control control = (Control) _helper.CreateControl (typeof (TestButton),  null);
			Control nestedControl = new TestButton ();
			
			// The following two tests show that the DT Site:
			//  * offers the added site-specific services via IServiceProvider
			// 	* doesn't offer its implementation of IServiceContainer as a site-specific service
			//  * GetService is routed through the owner
			// 
			INestedContainer nestedContainer = control.Site.GetService (typeof (INestedContainer)) as INestedContainer;
			nestedContainer.Add (nestedControl);

			((IServiceContainer) nestedControl.Site).AddService (typeof (DesignSurfaceTest), new DesignSurfaceTest ());
			Assert.IsNotNull (nestedControl.Site.GetService (typeof (DesignSurfaceTest)), "#1");
			Assert.AreEqual (nestedControl.Site.GetService (typeof (IServiceContainer)), 
							 _helper.DesignSurface.GetService (typeof (IServiceContainer)), "#2");
			Assert.IsNotNull (nestedControl.Site.GetService (typeof (DesignSurface)), "#3");
		}
Beispiel #38
0
		public void ApplyTemplateTest ()
		{
			Button b = new Button ();

			Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (b), "1");

			b.ApplyTemplate ();

			Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (b), "2");

			TestButton tb = new TestButton ();

			Assert.IsFalse (tb.NameFound, "3");
		}