Ejemplo n.º 1
0
        public void TestSize()
        {
            var  selector = new WPFListBox(target);
            Size size     = selector.Dynamic().RenderSize;

            Assert.AreEqual(new System.Drawing.Size((int)size.Width, (int)size.Height), selector.Size);
        }
Ejemplo n.º 2
0
        public void GetItemDriverTest()
        {
            var listEx = new WPFListBox <ItemControlDriver>(listBox.AppVar);

            listEx.EmulateChangeSelectedIndex(0);
            Assert.AreEqual("value 1", listEx.GetItemDriver(1).Text.Text);
        }
Ejemplo n.º 3
0
        public void TestPointToScreen()
        {
            var   selector = new WPFListBox(target);
            Point size     = selector.Dynamic().PointToScreen(new Point());

            Assert.AreEqual(new System.Drawing.Point((int)size.X, (int)size.Y), selector.PointToScreen(new System.Drawing.Point()));
        }
Ejemplo n.º 4
0
        public void TestIsEnabled()
        {
            var selector = new WPFListBox(target);

            Assert.IsTrue(selector.IsEnabled);
            selector.Dynamic().IsEnabled = false;
            Assert.IsFalse(selector.IsEnabled);
        }
Ejemplo n.º 5
0
        public void TestVisibility()
        {
            var selector = new WPFListBox(target);

            Assert.AreEqual(Visibility.Visible, selector.Visibility);
            selector.Dynamic().Visibility = Visibility.Hidden;
            Assert.AreEqual(Visibility.Hidden, selector.Visibility);
        }
 public void TestIsEnabled()
 {
     var win = app.Type(typeof(Application)).Current.MainWindow;
     var selector = new WPFListBox(target);
     Assert.IsTrue(selector.IsEnabled);
     selector.Dynamic().IsEnabled = false;
     Assert.IsFalse(selector.IsEnabled);
 }
 public void TestVisibility()
 {
     var win = app.Type(typeof(Application)).Current.MainWindow;
     var selector = new WPFListBox(target);
     Assert.AreEqual(Visibility.Visible, selector.Visibility);
     selector.Dynamic().Visibility = Visibility.Hidden;
     Assert.AreEqual(Visibility.Hidden, selector.Visibility);
 }
Ejemplo n.º 8
0
        public void ListViewActiveItemIndexTest()
        {
            var listEx = new WPFListBox <ItemDriver>(_ctrl._listView);

            listEx.GetItem(1).VisualTree().ByType <TextBox>()[0].Dynamic().Focus();

            Assert.AreEqual(-1, listEx.SelectedIndex);
            Assert.AreEqual(1, listEx.ActiveItemIndex);
        }
 public void TestInitialize() {
     app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
     dynamic win = app.Type(typeof(Application)).Current.MainWindow;
     dynamic grid = win._grid;
     dynamic target = app.Type<ListBox>()();
     grid.Children.Add(target);
     target.ItemsSource = Enumerable.Range(0, 100).Select(i => "value " + i).ToArray();
     listBox = new WPFListBox(target);
 }
Ejemplo n.º 10
0
        public void TestInitialize()
        {
            app = new WindowsAppFriend(Process.Start("Target.exe"));
            WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
            dynamic win    = app.Type(typeof(Application)).Current.MainWindow;
            dynamic grid   = win._grid;
            dynamic target = app.Type <ListBox>()();

            grid.Children.Add(target);
            target.ItemsSource = Enumerable.Range(0, 100).Select(i => "value " + i).ToArray();
            listBox            = new WPFListBox(target);
        }
Ejemplo n.º 11
0
        public void TestActivate()
        {
            var win    = new WindowControl(app.Type(typeof(Application)).Current.MainWindow);
            var newWin = app.Type <Window>()();

            newWin.Show();
            var selector = new WPFListBox(target);

            selector.Activate();

            Assert.AreEqual(WindowControl.FromZTop(app).Handle, win.Handle);
            Assert.IsTrue((bool)selector.Dynamic().IsFocused);
            newWin.Close();
        }
Ejemplo n.º 12
0
        public void コントロール特定2()
        {
            AppVar main = _app.Type <Application>().Current.MainWindow;

            var tab = new WPFTabControl(main.LogicalTree().ByType <TabControl>().Single());

            tab.EmulateChangeSelectedIndex(1);

            var userControl = main.LogicalTree().ByType("WpfApplication.DemoItemsControl").Single();
            var listBox     = new WPFListBox(userControl.LogicalTree().ByType <ListBox>().Single());

            var textBoxAge = new WPFTextBox(listBox.GetItem(2).VisualTree().ByBinding("Age").Single());

            textBoxAge.EmulateChangeText("50");
        }
        public void WPF()
        {
            var app = new WindowsAppFriend(Process.Start("Wpf.exe"));
            var window = app.Type().System.Windows.Application.Current.MainWindow;

            //ガタガタ言わずにx:Name使えばいいじゃん。
            var _textBox = new WPFTextBox(window._textBox);
            _textBox.EmulateChangeText("x:Name最高!");

            //嫌って言う人いるから頑張ったよ。
            AppVar windowAppVar = window;
            var logicalTree = windowAppVar.LogicalTree();
            var textBox = new WPFTextBox(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBox>().Single());
            var textBlock = new WPFTextBlock(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBlock>().Single());
            var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single());
            var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single());
            var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single());
            var listBox = new WPFListBox(logicalTree.ByBinding("Persons").Single());

            //VisualTreeにしか現れない要素は気を付けて
            var item = listBox.GetItem(20);
            var itemText = new WPFTextBlock(item.VisualTree().ByBinding("Name").Single());

            //これでもダメな場合は工夫してね!

            Process.GetProcessById(app.ProcessId).Kill();
        }
 void Assert(string accessPath, WPFListBox listBox)
 => CaptureAdaptor.AddCode($"{accessPath}.SelectedIndex.Is({listBox.SelectedIndex});");