Пример #1
0
		public void ParentMenu_ChildrenStates ()
		{
			BasicWidgetType type = BasicWidgetType.ParentMenu;
			Atk.Object accessible = null;

			string menuName = "File";
			MenuLayout [] firstSubmenus = new MenuLayout [] { new MenuLayout ("New...", new MenuLayout ("Project"), new MenuLayout ("Text")), new MenuLayout ("Quit!") };

			List <MenuLayout> menu = new List <MenuLayout> ();
			menu.Add (new MenuLayout (menuName, firstSubmenus));
			menu.Add (new MenuLayout ("Help", new MenuLayout ("About?")));

			accessible = GetAccessible (type, menu);

			List <string> names = new List <string> ();
			names.Add (menuName);
			foreach (MenuLayout submenu in firstSubmenus)
				names.Add (submenu.Label);

			//we check this when the ParentMenu is open (bnc#479397)
			int j = 0;
			names.Remove (menuName);
			RunInGuiThread (delegate () {
				CastToAtkInterface <Atk.IAction> (accessible).DoAction (0);
			});
			Atk.ISelection atkSelection = CastToAtkInterface <Atk.ISelection> (accessible);

			Assert.IsTrue (accessible.RefAccessibleChild (0).RefStateSet ().ContainsState (Atk.StateType.Showing));
			foreach (string name in names) {
				Assert.AreEqual (accessible.RefAccessibleChild (j).Name, name);
				States (accessible.RefAccessibleChild (j),
				        Atk.StateType.Enabled,
				        IsBGO580460Addressed () ? Atk.StateType.Focusable : Atk.StateType.Enabled,
				        Atk.StateType.Selectable,
				        Atk.StateType.Sensitive,
				        Atk.StateType.Showing,
				        Atk.StateType.Visible);
				atkSelection.AddSelection (j);
				States (accessible.RefAccessibleChild (j),
				        Atk.StateType.Enabled,
				        (IsBGO580452Addressed () || j != 0) ? Atk.StateType.Focused : Atk.StateType.Enabled,
				        IsBGO580452Addressed () ? Atk.StateType.Focusable : Atk.StateType.Enabled,
				        Atk.StateType.Selected,
				        Atk.StateType.Selectable,
				        Atk.StateType.Sensitive,
				        Atk.StateType.Showing,
				        Atk.StateType.Visible);
				j++;
			}
		}
Пример #2
0
		public virtual void ContextMenu (BasicWidgetType type) 
		{
			MenuLayout [] firstSubmenus = new MenuLayout [] { new MenuLayout ("Schema", new MenuLayout ("XSD"), new MenuLayout ("DTD")), new MenuLayout ("Source") };
			List <MenuLayout> menu = new List <MenuLayout> ();
			menu.Add (new MenuLayout ("Edit", firstSubmenus));
			menu.Add (new MenuLayout ("Close"));

			int expectedNumOfWindows = GetTopLevelRootItem ().NAccessibleChildren + 1;
			
			Atk.Object accessible = GetAccessible (type, menu);

			int currentTopLevelItems = 0;
			try {
				Interfaces (accessible,
				            typeof (Atk.IComponent),
				            typeof (Atk.ISelection));
				Assert.AreEqual (expectedNumOfWindows, GetTopLevelRootItem ().NAccessibleChildren,
				                 "Windows in my app should be " + expectedNumOfWindows + 
				                 "but I got:" + DescribeChildren (GetTopLevelRootItem ()));
	
				Assert.IsNull (accessible.Name, "name of the menubar should be null, now it's:" + accessible.Name);
	
				PropertyRole (type, accessible);
	
				Assert.AreEqual (accessible.Parent.Role, Atk.Role.Window);
	
				Assert.AreEqual (accessible.Parent.Parent, GetTopLevelRootItem ());
				
				States (accessible,
				  Atk.StateType.Focused,
				  Atk.StateType.Enabled,
				  Atk.StateType.Sensitive,
				  Atk.StateType.Visible,
				  Atk.StateType.Showing);
	
				Assert.AreEqual (menu.Count, accessible.NAccessibleChildren, 
				                 "number of children; children roles:" + DescribeChildren (accessible));
	
				for (int i = 0; i < accessible.NAccessibleChildren; i++) {
					Atk.Object menuChild = accessible.RefAccessibleChild (i);
					Assert.IsNotNull (menuChild, "menu child#0 should not be null");
					Assert.IsTrue (
					  ((menuChild.Role == Atk.Role.Menu) ||
					   (menuChild.Role == Atk.Role.MenuItem) ||
					   (menuChild.Role == Atk.Role.TearOffMenuItem) ||
					   (menuChild.Role == Atk.Role.Separator)), "valid roles for a child of a parentMenu");
					
					Assert.IsTrue (menuChild.NAccessibleChildren > 0 || (menuChild.Role != Atk.Role.Menu),
					   "only grandchildren allowed if parent is menu; here we got " + menuChild.NAccessibleChildren +
					   " children, with role " + menuChild.Role + "on the item number" + i);
	
					Assert.AreEqual (menuChild.Name, menu [i].Label, "name of the menu is the same as its label");
				}
				
				Atk.IComponent atkComponent = CastToAtkInterface <Atk.IComponent> (accessible);
				InterfaceComponent (type, atkComponent);
	
				List <string> names = new List <string> ();
				foreach (MenuLayout submenu in menu)
					names.Add (submenu.Label);
				Atk.ISelection atkSelection = CastToAtkInterface <Atk.ISelection> (accessible);
				RunInGuiThread (delegate (){
					InterfaceSelection (atkSelection, names.ToArray (), accessible, type);
				});
			} catch {
				currentTopLevelItems = -1;
				throw;
			} finally {
				if (currentTopLevelItems != -1)
					currentTopLevelItems = GetTopLevelRootItem ().NAccessibleChildren;
				CloseContextMenu (accessible);
				if (currentTopLevelItems != -1)
					Assert.AreEqual (GetTopLevelRootItem ().NAccessibleChildren, currentTopLevelItems - 1,
					                 "ContextMenu has not disappeared from the hierarchy!");
			}
		}
Пример #3
0
		public void ParentMenu () 
		{
			BasicWidgetType type = BasicWidgetType.ParentMenu;
			Atk.Object accessible = null;

			string menuName = "File";
			MenuLayout [] firstSubmenus = new MenuLayout [] { new MenuLayout ("New...", new MenuLayout ("Project"), new MenuLayout ("Text")), new MenuLayout ("Quit!") };

			List <MenuLayout> menu = new List <MenuLayout> ();
			menu.Add (new MenuLayout (menuName, firstSubmenus));
			menu.Add (new MenuLayout ("Help", new MenuLayout ("About?")));

			accessible = GetAccessible (type, menu);
			
			Assert.AreEqual (menuName, accessible.Name, "name of the menu is the same as its label");

			PropertyRole (type, accessible);

			States (accessible,
			  Atk.StateType.Enabled,
			  Atk.StateType.Selectable, 
			  Atk.StateType.Sensitive,
			  Atk.StateType.Visible,
			  Atk.StateType.Showing);

			Assert.AreEqual (firstSubmenus.Length, accessible.NAccessibleChildren, 
			                 "number of children; children roles:" + DescribeChildren (accessible));

			for (int i = 0; i < accessible.NAccessibleChildren; i++) {
				Atk.Object menuChild = accessible.RefAccessibleChild (i);
				Assert.IsNotNull (menuChild, "menu child#0 should not be null");
				Assert.IsTrue (
				  ((menuChild.Role == Atk.Role.Menu) ||
				   (menuChild.Role == Atk.Role.MenuItem) ||
				   (menuChild.Role == Atk.Role.TearOffMenuItem) ||
				   (menuChild.Role == Atk.Role.Separator)), "valid roles for a child of a parentMenu");
				
				Assert.IsTrue (menuChild.NAccessibleChildren > 0 || (menuChild.Role != Atk.Role.Menu),
				   "only grandchildren allowed if parent is menu; here we got " + menuChild.NAccessibleChildren +
				   " children, with role " + menuChild.Role + " on the item number" + i);

				Assert.AreEqual (menuChild.Name, firstSubmenus [i].Label, "name of the menu is the same as its label");
			}

			Atk.IComponent atkComponent = CastToAtkInterface <Atk.IComponent> (accessible);
			InterfaceComponent (type, atkComponent);

			List <string> names = new List <string> ();
			names.Add (menuName);
			foreach (MenuLayout submenu in firstSubmenus)
				names.Add (submenu.Label);
			Atk.ISelection atkSelection = CastToAtkInterface <Atk.ISelection> (accessible);
			InterfaceSelection (atkSelection, names.ToArray (), accessible, type);

			Atk.IAction atkAction = CastToAtkInterface <Atk.IAction> (accessible);
			InterfaceAction (type, atkAction, accessible);

			menu = new List <MenuLayout> (new MenuLayout [] { new MenuLayout (simpleTestText, firstSubmenus), new MenuLayout ("Help") });
			accessible = GetAccessible (type, menu);
			InterfaceText (type, true, accessible);
		}
Пример #4
0
		public void ChildMenuSeparator () 
		{
			BasicWidgetType type = BasicWidgetType.ChildMenuSeparator;
			Atk.Object accessible = null;

			string menuName = "File";
			MenuLayout [] firstSubmenus = 
				new MenuLayout [] { 
					new MenuLayout ("New...", 
						new MenuLayout ("Project"), 
						new MenuLayout ("Text")), 
					new MenuSeparator (), 
					new MenuLayout ("Quit!") };

			List <MenuLayout> menu = new List <MenuLayout> ();
			menu.Add (new MenuLayout (menuName, firstSubmenus));
			menu.Add (new MenuLayout ("Help", new MenuLayout ("About?")));

			accessible = GetAccessible (type, menu);
			
			Assert.AreEqual (null, accessible.Name, "separator.Name==null");
			Assert.AreEqual (menuName, accessible.Parent.Name, "separator.Name==null");

			PropertyRole (type, accessible);

			//In Gail, action and text are ridiculously implemented, so I don't want to enable this:
			if (IsBGO567991Addressed ())
				Interfaces (accessible,
				            typeof (Atk.IComponent));
			else
				Interfaces (accessible,
				            typeof (Atk.IComponent),
				            typeof (Atk.IAction),
				            typeof (Atk.IText));
			
			Assert.AreEqual (0, accessible.NAccessibleChildren, 
			                 "number of children; children roles:" + DescribeChildren (accessible));

			States (accessible,
			  Atk.StateType.Enabled,
			  Atk.StateType.Selectable, 
			  Atk.StateType.Sensitive,
			  Atk.StateType.Visible);

			RunInGuiThread (delegate {
				CastToAtkInterface <Atk.IAction> (accessible.Parent).DoAction (0);
			});
				
			States (accessible,
			  Atk.StateType.Enabled,
			  Atk.StateType.Selectable, 
			  Atk.StateType.Sensitive,
			  Atk.StateType.Visible,
			  Atk.StateType.Showing);
			
			Atk.IComponent atkComponent = CastToAtkInterface <Atk.IComponent> (accessible);
			InterfaceComponent (type, atkComponent);

			RunInGuiThread (delegate {
				CastToAtkInterface <Atk.IAction> (accessible.Parent).DoAction (0);
			});
			

		}