def test_normal_button(self): from generalElements.buttons.NormalButton import NormalButton button = NormalButton(text="Bonjour") self.root = button self.render(self.root) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.inspect_enabled = True # touch button center touch = UnitTestTouch(*self.root.center) touch.touch_down() touch.touch_up() self.assertIsInstance(ins.widget, NormalButton) self.advance_frames(2) self.assertEqual(ins.widget.text, 'Bonjour') # close Inspector ins.inspect_enabled = False ins.activated = False # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2)
def test_widget_button(self, *args): EventLoop.ensure_window() self._win = EventLoop.window self.clean_garbage() # build the widget tree & add Window as the main EL self.root = self.builder.Builder.load_string( KV, filename="InspectorTestCase.KV") self.render(self.root) self.assertLess(len(self._win.children), 2) # checked widget highlight = self.root.ids.highlight highlight_exp = self.root.ids.highlight.text # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(2) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.inspect_enabled = True self.assertTrue(ins.at_bottom) # touch button center touch = UnitTestTouch(*highlight.center) touch.touch_down() touch.touch_up() # open Inspector properties ins.show_widget_info() self.advance_frames(2) # check if the button is selected # stored instance self.assertEqual(ins.widget.text, highlight_exp) # data in properties for node in ins.treeview.iterate_all_nodes(): lkey = getattr(node.ids, 'lkey', None) if not lkey: continue if lkey.text == 'text': ltext = node.ids.ltext # slice because the string is displayed with quotes self.assertEqual(ltext.text[1:-1], highlight_exp) break # close Inspector ins.inspect_enabled = False ins.activated = False self.render(self.root) self.advance_frames(1) # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) self.render(self.root)
def test_explandable_base(self): from generalElements.buttons.ExpandableButton import ExpandableButton from generalElements.buttons.WideButton import WideButton from generalElements.buttons.RemoveButton import RemoveButton from kivy.uix.button import Button from kivy.uix.checkbox import CheckBox print('padding: ', self.app.padding) print('padding2:', App.get_running_app().padding) button = ExpandableButton() self.root = button self.render(self.root) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom ins = self.root.inspector # ins.at_bottom = False ins.activated = True ins.inspect_enabled = True but = Button(text='Move to Top') ins.toggle_position(but) # self.assertFalse(ins.at_bottom) self.advance_frames(5) # touch button center touch = UnitTestTouch(*self.root.ids.expandable_checkbox.center) touch.touch_down() touch.touch_up() self.__inspect_node(ins) ins = self.root.inspector self.assertIsInstance(ins.widget, CheckBox) self.advance_frames(2) touch = UnitTestTouch(*self.root.ids.expandable_wide_button.center) touch.touch_down() touch.touch_up() self.assertIsInstance(ins.widget, WideButton) self.__inspect_node(ins) self.advance_frames(2) touch = UnitTestTouch(*self.root.ids.expandable_remove_button.center) touch.touch_down() touch.touch_up() self.assertIsInstance(ins.widget, RemoveButton) self.advance_frames(2) # close Inspector ins.inspect_enabled = False ins.activated = False # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2)
def test_Vertical_button(self): from generalElements.buttons.VerticalButton import VerticalButton from kivy.uix.label import Label self.root = VerticalButton(vertical_text="allo", group='gomp') self.render(self.root) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.at_bottom = False ins.inspect_enabled = True pos = Button(text="Move to Top") ins.toggle_position(pos) self.assertFalse(ins.at_bottom) self.advance_frames(5) # touch button center touch = UnitTestTouch(*self.root.center) touch.touch_down() touch.touch_up() self.__inspect_node(self.root.inspector) # ins = self.root.inspector self.assertIsInstance(ins.widget, Label) self.advance_frames(2) self.__inspect_node(ins) self.assertEqual(ins.widget.text, 'allo') # close Inspector ins.inspect_enabled = False ins.activated = False # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2)
def test_activate_deactivate_top(self, *args): EventLoop.ensure_window() self._win = EventLoop.window self.clean_garbage() # build the widget tree & add Window as the main EL self.root = self.builder.Builder.load_string( KV, filename="InspectorTestCase.KV") self.render(self.root) self.assertLess(len(self._win.children), 2) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(2) # pull the Inspector drawer from top ins = self.root.inspector ins.at_bottom = False ins.activated = True ins.inspect_enabled = True self.assertFalse(ins.at_bottom) # by default is Inspector appended as the first child # to the window & we move it to the top self.assertEqual(self._win.children[0], ins) ins.toggle_position(self.root.ids.dummy) self.advance_frames(20) # drawer is moving, like with activate self.assertGreater(ins.layout.pos[1], self._win.height / 2.0) # close Inspector ins.inspect_enabled = False ins.activated = False self.render(self.root) self.advance_frames(1) # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) self.render(self.root)
def test_TootleBase(self): from generalElements.buttons.ToogleBase import ToggleBase self.root = ToggleBase(text='Bonjour', group='gomp') self.render(self.root) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.at_bottom = False ins.inspect_enabled = True pos = Button(text="Move to Top") ins.toggle_position(pos) self.assertFalse(ins.at_bottom) self.advance_frames(5) # touch button center touch = UnitTestTouch(*self.root.center) touch.touch_down() touch.touch_up() ins = self.root.inspector self.assertIsInstance(ins.widget, ToggleBase) self.advance_frames(2) self.assertEqual(ins.widget.text, 'Bonjour') # close Inspector ins.inspect_enabled = False ins.activated = False # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2)
def test_activate_deactivate_bottom(self, *args): EventLoop.ensure_window() self._win = EventLoop.window self.clean_garbage() # build the widget tree & add Window as the main EL self.root = self.builder.Builder.load_string(KV) self.render(self.root) self.assertLess(len(self._win.children), 2) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(2) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.inspect_enabled = True self.assertTrue(ins.at_bottom) # by default is Inspector appended as the first child # to the window and positioned at the bottom self.assertEqual(self._win.children[0], ins) self.advance_frames(1) self.assertLess(ins.layout.pos[1], self._win.height / 2.0) # close Inspector ins.inspect_enabled = False ins.activated = False self.render(self.root) self.advance_frames(1) # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) self.render(self.root)
def test_button_base(self): # build the button from generalElements.buttons.ButtonBase import ButtonBase button = ButtonBase(text="Bonjour", always_release=True) self.root = button self.render(self.root) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.inspect_enabled = True self.assertTrue(ins.at_bottom) # touch button center touch = UnitTestTouch(*self.root.center) touch.touch_down() touch.touch_up() self.assertIsInstance(ins.widget, ButtonBase) # check if the button is selected self.assertEqual(ins.widget.text, 'Bonjour') # self.__inspect_node(ins) # close Inspector ins.inspect_enabled = False ins.activated = False # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2)
def test_AlbumSortDropDown(self): self.advance_frames(100) from generalElements.dropDowns.AlbumSortDropDown import AlbumSortDropDown from generalElements.buttons.MenuButton import MenuButton dropDown = AlbumSortDropDown() self.root = dropDown self.render(self.root) self.advance_frames(10) # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom ins = self.root.inspector ins.activated = True ins.at_bottom = False ins.inspect_enabled = True self.assertFalse(ins.at_bottom) self.advance_frames(5) pos = Button(text="Move to Top") ins.toggle_position(pos) self.advance_frames(50) self.render(self.root) self.advance_frames(50) touch = UnitTestTouch(*self.root.ids.sort_by_name.center) touch.touch_down() touch.touch_up() self.advance_frames(50) self.assertIsInstance(ins.widget,MenuButton) self.assertEqual(ins.widget.text,'Name') touch = UnitTestTouch(*self.root.ids.sort_by_path.center) touch.touch_down() touch.touch_up() #ins.show_widget_info() self.assertIsInstance(ins.widget,MenuButton) self.assertEqual(ins.widget.text,'Path') self.advance_frames(1) touch = UnitTestTouch(*self.root.ids.sort_by_imported.center) touch.touch_down() touch.touch_up() self.assertIsInstance(ins.widget,MenuButton) self.assertEqual(ins.widget.text,'Imported') self.advance_frames(1) touch = UnitTestTouch(*self.root.ids.sort_by_modified.center) touch.touch_down() touch.touch_up() self.assertIsInstance(ins.widget,MenuButton) self.assertEqual(ins.widget.text,'Modified') self.advance_frames(1) # close Inspector ins.inspect_enabled = False ins.activated = False # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) pass
def test_widget_multipopup(self, *args): EventLoop.ensure_window() self._win = EventLoop.window self.clean_garbage() # build the widget tree & add Window as the main EL self.root = self.builder.Builder.load_string(KV) self.render(self.root) self.assertLess(len(self._win.children), 2) # checked widget popup = self.root.ids.popup popup_exp = self.root.ids.popup.text # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom, # but don't inspect yet! ins = self.root.inspector ins.inspect_enabled = False ins.activated = True self.assertTrue(ins.at_bottom) # touch button center to open the popup touch = UnitTestTouch(*popup.center) touch.touch_down() touch.touch_up() self.advance_frames(1) # touch Window center to open # the second and the third popup touch = UnitTestTouch(self._win.width / 2.0, self._win.height / 2.0) for i in range(2): touch.touch_down() touch.touch_up() self.advance_frames(1) # fixed order, first opened - last closed modals = (Factory.ThirdModal, Factory.SecondModal, Factory.FirstModal) for mod in modals: # start inspecting ins.inspect_enabled = True self.advance_frames(1) # inspect button touch.touch_down() touch.touch_up() self.advance_frames(1) # check if the popup is selected # stored instance self.assertIsInstance(ins.widget, Factory.Button) self.assertIsInstance(ins.widget.parent, mod) # close popup ins.inspect_enabled = False orig = UnitTestTouch(0, 0) orig.touch_down() orig.touch_up() self.advance_frames(10) # close Inspector ins.activated = False self.render(self.root) self.advance_frames(10) # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) self.render(self.root)
def test_widget_popup(self, *args): EventLoop.ensure_window() self._win = EventLoop.window self.clean_garbage() # build the widget tree & add Window as the main EL self.root = self.builder.Builder.load_string(KV) self.render(self.root) self.assertLess(len(self._win.children), 2) # checked widget popup = self.root.ids.popup popup_exp = self.root.ids.popup.text # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom, # but don't inspect yet! ins = self.root.inspector ins.inspect_enabled = False ins.activated = True self.assertTrue(ins.at_bottom) # touch button center to open the popup touch = UnitTestTouch(*popup.center) touch.touch_down() touch.touch_up() self.advance_frames(1) # start inspecting ins.inspect_enabled = True self.advance_frames(1) # inspect FirstModal's button touch.touch_down() touch.touch_up() self.advance_frames(1) # open Inspector properties ins.show_widget_info() self.advance_frames(2) # check if the popup is selected # stored instance self.assertIsInstance(ins.widget, Factory.Button) self.assertIsInstance(ins.widget.parent, Factory.FirstModal) # check with new Popup instance if the properties match temp_popup = Factory.FirstModal() temp_popup_exp = temp_popup.ids.firstmodal.text self.assertEqual(ins.widget.text, temp_popup_exp) # data in properties for node in ins.treeview.iterate_all_nodes(): lkey = getattr(node.ids, 'lkey', None) if not lkey: continue if lkey.text == 'text': ltext = node.ids.ltext # slice because the string is displayed with quotes self.assertEqual(ltext.text[1:-1], temp_popup_exp) break del temp_popup # close popup ins.inspect_enabled = False touch = UnitTestTouch(0, 0) touch.touch_down() touch.touch_up() self.advance_frames(10) # close Inspector ins.activated = False self.render(self.root) self.advance_frames(10) # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) self.render(self.root)
def test_widget_multipopup(self, *args): EventLoop.ensure_window() self._win = EventLoop.window self.clean_garbage() # build the widget tree & add Window as the main EL self.root = self.builder.Builder.load_string(KV) self.render(self.root) self.assertLess(len(self._win.children), 2) # checked widget popup = self.root.ids.popup popup_exp = self.root.ids.popup.text # activate inspector with root as ctx inspector.start(self._win, self.root) self.advance_frames(1) # pull the Inspector drawer from bottom, # but don't inspect yet! ins = self.root.inspector ins.inspect_enabled = False ins.activated = True self.assertTrue(ins.at_bottom) # touch button center to open the popup touch = UnitTestTouch(*popup.center) touch.touch_down() touch.touch_up() self.advance_frames(1) # touch Window center to open # the second and the third popup touch = UnitTestTouch( self._win.width / 2.0, self._win.height / 2.0 ) for i in range(2): touch.touch_down() touch.touch_up() self.advance_frames(1) # fixed order, first opened - last closed modals = ( Factory.ThirdModal, Factory.SecondModal, Factory.FirstModal ) for mod in modals: # start inspecting ins.inspect_enabled = True self.advance_frames(1) # inspect button touch.touch_down() touch.touch_up() self.advance_frames(1) # check if the popup is selected # stored instance self.assertIsInstance(ins.widget, Factory.Button) self.assertIsInstance(ins.widget.parent, mod) # close popup ins.inspect_enabled = False orig = UnitTestTouch(0, 0) orig.touch_down() orig.touch_up() self.advance_frames(10) # close Inspector ins.activated = False self.render(self.root) self.advance_frames(10) # stop Inspector completely inspector.stop(self._win, self.root) self.assertLess(len(self._win.children), 2) self.render(self.root)