def test_grid_resize(self): test.set_sleep_time(300) gp = self.frame.grid_panel gui_loop() self.frame.SetSize((600, 600)) self.frame.Center()
def test_plot_viewport(self): test.set_sleep_time(100) vwp = viewport.PlotViewport(self.panel) vwp.canvas.SetBackgroundColour("#333") self.add_control(vwp, wx.EXPAND, proportion=1) vwp.canvas.SetForegroundColour("#27C4CC") for mode in MODES: vwp.canvas.set_plot_mode(mode) for plot in BAD_RANGED_PLOTS: with self.assertRaises(ValueError): vwp.canvas.set_1d_data(plot[2], plot[3], range_x=plot[0], range_y=plot[1]) test.gui_loop() vwp.Refresh() for plot in BAD_PLOTS: with self.assertRaises(ValueError): vwp.canvas.set_1d_data(plot[0], plot[1]) test.gui_loop() vwp.Refresh() for plot in PLOTS: vwp.canvas.set_1d_data(plot[0], plot[1]) vwp.bottom_legend.range = (min(plot[0]), max(plot[0])) vwp.left_legend.range = (min(plot[1]), max(plot[1])) test.gui_loop() vwp.Refresh() for plot in RANGED_PLOTS[:-1]: vwp.canvas.set_1d_data(plot[2], plot[3], range_x=plot[0], range_y=plot[1]) vwp.bottom_legend.range = (min(plot[0]), max(plot[0])) vwp.left_legend.range = (min(plot[1]), max(plot[1])) test.gui_loop() vwp.Refresh()
def test_grid_edit(self): test.set_sleep_time(200) gp = self.frame.grid_panel gui_loop() self.assertRaises(ValueError, gp.swap_viewports, self.frame.red, self.frame.yellow) gp.swap_viewports(self.frame.red, self.frame.yellow) gp.hide_viewport(self.frame.red) gp.swap_viewports(self.frame.red, self.frame.yellow) gp.show_viewport(self.frame.yellow) gui_loop() self.assertEqual(self.frame.yellow.Position, (0, 0)) gp.hide_viewport(self.frame.yellow) gp.swap_viewports(self.frame.red, self.frame.yellow) gp.show_viewport(self.frame.red) gui_loop() self.assertEqual(self.frame.red.Position, (0, 0))
def test_grid_view(self): test.set_sleep_time(200) gp = self.frame.grid_panel gui_loop() csize = self.frame.ClientSize # Hide 1 windows # Hide top left gp.hide_viewport(self.frame.red) self.assertEqual(self.frame.blue.Size, (csize.x, gp.grid_layout.tr.size.y)) self.assertEqual(self.frame.purple.Size, gp.grid_layout.bl.size) self.assertEqual(self.frame.brown.Size, gp.grid_layout.br.size) gui_loop() gp.show_viewport(self.frame.red) # Hide top right gp.hide_viewport(self.frame.blue) self.assertEqual(self.frame.red.Size, (csize.x, gp.grid_layout.tl.size.y)) self.assertEqual(self.frame.purple.Size, gp.grid_layout.bl.size) self.assertEqual(self.frame.brown.Size, gp.grid_layout.br.size) gui_loop() gp.show_viewport(self.frame.blue) # Hide bottom left gp.hide_viewport(self.frame.purple) self.assertEqual(self.frame.red.Size, gp.grid_layout.tl.size) self.assertEqual(self.frame.blue.Size, gp.grid_layout.tr.size) self.assertEqual(self.frame.brown.Size, (csize.x, gp.grid_layout.br.size.y)) gui_loop() gp.show_viewport(self.frame.purple) # Hide bottom right gp.hide_viewport(self.frame.brown) self.assertEqual(self.frame.red.Size, gp.grid_layout.tl.size) self.assertEqual(self.frame.blue.Size, gp.grid_layout.tr.size) self.assertEqual(self.frame.purple.Size, (csize.x, gp.grid_layout.bl.size.y)) gui_loop() gp.show_viewport(self.frame.brown) # Hide 2 windows # Hide top gp.hide_viewport(self.frame.red) gp.hide_viewport(self.frame.blue) self.assertEqual(self.frame.purple.Size, (gp.grid_layout.bl.size.x, csize.y)) self.assertEqual(self.frame.brown.Size, (gp.grid_layout.br.size.x, csize.y)) gui_loop() gp.show_viewport(self.frame.red) gp.show_viewport(self.frame.blue) # Hide right gp.hide_viewport(self.frame.blue) gp.hide_viewport(self.frame.brown) self.assertEqual(self.frame.red.Size, (csize.x, gp.grid_layout.tl.size.y)) self.assertEqual(self.frame.purple.Size, (csize.x, gp.grid_layout.bl.size.y)) gui_loop() gp.show_viewport(self.frame.brown) gp.show_viewport(self.frame.blue) # Hide bottom gp.hide_viewport(self.frame.purple) gp.hide_viewport(self.frame.brown) self.assertEqual(self.frame.red.Size, (gp.grid_layout.tl.size.x, csize.y)) self.assertEqual(self.frame.blue.Size, (gp.grid_layout.tr.size.x, csize.y)) gui_loop() gp.show_viewport(self.frame.brown) gp.show_viewport(self.frame.purple) # Hide left gp.hide_viewport(self.frame.red) gp.hide_viewport(self.frame.purple) self.assertEqual(self.frame.blue.Size, (csize.x, gp.grid_layout.tr.size.y)) self.assertEqual(self.frame.brown.Size, (csize.x, gp.grid_layout.br.size.y)) gui_loop() gp.show_viewport(self.frame.purple) gp.show_viewport(self.frame.red) # Hide 3 windows gp.set_shown_viewports(self.frame.red) self.assertEqual(self.frame.red.Size, csize) gui_loop() gp.set_shown_viewports(self.frame.blue) self.assertEqual(self.frame.blue.Size, csize) gui_loop() gp.set_shown_viewports(self.frame.purple) self.assertEqual(self.frame.purple.Size, csize) gui_loop() gp.set_shown_viewports(self.frame.brown) self.assertEqual(self.frame.brown.Size, csize) gui_loop() gp.set_shown_viewports(self.frame.yellow) self.assertEqual(self.frame.yellow.Size, csize) gui_loop() gp.show_grid_viewports()
def test_foldpanel_manipulation(self): test.set_sleep_time(100) appfpb = self.app.test_frame.fpb fpb_height = appfpb.BestSize.GetHeight() # Add an extra fold panel new_panel = appfpb.create_and_add_item("Test panel 4", False) self.app.test_frame.Layout() test.gui_loop(100) # The height of the parent should be 42 pixels higher # (CaptionBar height + 1px border) self.assertEqual(fpb_height + 42, appfpb.BestSize.GetHeight()) self.assertEqual(len(appfpb.GetChildren()), 4) test.gui_loop(100) new_panel.add_item(wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL")) test.gui_loop(100) # A scroll bars should not appear yet self.assertEqual(appfpb.has_vert_scrollbar(), False) self.assertEqual(appfpb.has_horz_scrollbar(), False) for i in range(6): new_panel.add_item(wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL %d" % i)) test.gui_loop(100) # Vertical scroll bar should have appeared self.assertEqual(appfpb.has_vert_scrollbar(), True) self.assertEqual(appfpb.has_horz_scrollbar(), False) new_panel.add_item(wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL")) new_panel.add_item(wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL")) test.gui_loop(100) # 10 Child windows in the new panel self.assertEqual(len(new_panel._container.GetChildren()), 9) # 4 fold panels total in the bar self.assertEqual(len(appfpb.GetChildren()), 4) wx.MilliSleep(test.SLEEP_TIME) appfpb.remove_item(new_panel) test.gui_loop(100) # New panel removed, back to 3 self.assertEqual(len(appfpb.GetChildren()), 3) false_pos_warn = ("This might be a false positive. " "Run test module stand-alone to verify") # Scroll bars should be gone again self.assertEqual(appfpb.has_vert_scrollbar(), False, false_pos_warn) self.assertEqual(appfpb.has_horz_scrollbar(), False, false_pos_warn) wx.MilliSleep(test.SLEEP_TIME) top_panel = self.app.test_frame.panel_1 new_labels = [] for dummy in range(4): item = wx.StaticText(top_panel, top_panel.GetId(), "ADDED LABEL") top_panel.add_item(item) new_labels.append(item) test.gui_loop(100) # No Scroll bars yet self.assertEqual(appfpb.has_vert_scrollbar(), False, false_pos_warn) self.assertEqual(appfpb.has_horz_scrollbar(), False, false_pos_warn) test.gui_loop(100) item = wx.StaticText(top_panel, top_panel.GetId(), "ADDED LABEL") top_panel.add_item(item) new_labels.append(item) test.gui_loop(100) # Vertical Scroll bar self.assertEqual(appfpb.has_vert_scrollbar(), True, false_pos_warn) self.assertEqual(appfpb.has_horz_scrollbar(), False, false_pos_warn) # Count children of the top fold panel: 2 labels and 4 added labels: 6 total self.assertEqual(len(top_panel._container.GetChildren()), 7) new_labels.reverse() for label in new_labels: top_panel.remove_item(label) test.gui_loop(100) # Count children of the top fold panel: 1 caption bar, 2 labels self.assertEqual(len(top_panel._container.GetChildren()), 2) top_panel.remove_all() test.gui_loop(100) # Count children of the top fold panel: 1 caption bar self.assertEqual(len(top_panel._container.GetChildren()), 0) # Insert 3 windows, out of order, into the top fold panel item = wx.StaticText(top_panel, top_panel.GetId(), "LABEL 1") top_panel.insert_item(item, 0) test.gui_loop(100) item = wx.StaticText(top_panel, top_panel.GetId(), "LABEL 2") top_panel.insert_item(item, 0) test.gui_loop(100) item = wx.StaticText(top_panel, top_panel.GetId(), "LABEL 3") top_panel.insert_item(item, 0) test.gui_loop(100)
def test_foldpanel_manipulation(self): test.set_sleep_time(100) appfpb = self.app.test_frame.fpb fpb_height = appfpb.BestSize.GetHeight() # Add an extra fold panel new_panel = appfpb.create_and_add_item("Test panel 4", False) self.app.test_frame.Layout() test.gui_loop(0.1) # The height of the parent should be 42 pixels higher # (CaptionBar height + 1px border) self.assertEqual(fpb_height + 42, appfpb.BestSize.GetHeight()) self.assertEqual(len(appfpb.GetChildren()), 4) test.gui_loop(0.1) new_panel.add_item( wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL")) test.gui_loop(0.1) # A scroll bars should not appear yet self.assertEqual(appfpb.has_vert_scrollbar(), False) self.assertEqual(appfpb.has_horz_scrollbar(), False) for i in range(6): new_panel.add_item( wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL %d" % i)) test.gui_loop(0.1) # Vertical scroll bar should have appeared self.assertEqual(appfpb.has_vert_scrollbar(), True) self.assertEqual(appfpb.has_horz_scrollbar(), False) new_panel.add_item( wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL")) new_panel.add_item( wx.StaticText(new_panel, new_panel.GetId(), "ADDED LABEL")) test.gui_loop(0.1) # 10 Child windows in the new panel self.assertEqual(len(new_panel._container.GetChildren()), 9) # 4 fold panels total in the bar self.assertEqual(len(appfpb.GetChildren()), 4) wx.MilliSleep(test.SLEEP_TIME) appfpb.remove_item(new_panel) test.gui_loop(0.1) # New panel removed, back to 3 self.assertEqual(len(appfpb.GetChildren()), 3) false_pos_warn = ("This might be a false positive. " "Run test module stand-alone to verify") # Scroll bars should be gone again self.assertEqual(appfpb.has_vert_scrollbar(), False, false_pos_warn) self.assertEqual(appfpb.has_horz_scrollbar(), False, false_pos_warn) wx.MilliSleep(test.SLEEP_TIME) top_panel = self.app.test_frame.panel_1 new_labels = [] for dummy in range(4): item = wx.StaticText(top_panel, top_panel.GetId(), "ADDED LABEL") top_panel.add_item(item) new_labels.append(item) test.gui_loop(0.1) # No Scroll bars yet self.assertEqual(appfpb.has_vert_scrollbar(), False, false_pos_warn) self.assertEqual(appfpb.has_horz_scrollbar(), False, false_pos_warn) test.gui_loop(0.1) item = wx.StaticText(top_panel, top_panel.GetId(), "ADDED LABEL") top_panel.add_item(item) new_labels.append(item) test.gui_loop(0.1) # Vertical Scroll bar self.assertEqual(appfpb.has_vert_scrollbar(), True, false_pos_warn) self.assertEqual(appfpb.has_horz_scrollbar(), False, false_pos_warn) # Count children of the top fold panel: 2 labels and 4 added labels: 6 total self.assertEqual(len(top_panel._container.GetChildren()), 7) new_labels.reverse() for label in new_labels: top_panel.remove_item(label) test.gui_loop(0.1) # Count children of the top fold panel: 1 caption bar, 2 labels self.assertEqual(len(top_panel._container.GetChildren()), 2) top_panel.remove_all() test.gui_loop(0.1) # Count children of the top fold panel: 1 caption bar self.assertEqual(len(top_panel._container.GetChildren()), 0) # Insert 3 windows, out of order, into the top fold panel item = wx.StaticText(top_panel, top_panel.GetId(), "LABEL 1") top_panel.insert_item(item, 0) test.gui_loop(0.1) item = wx.StaticText(top_panel, top_panel.GetId(), "LABEL 2") top_panel.insert_item(item, 0) test.gui_loop(0.1) item = wx.StaticText(top_panel, top_panel.GetId(), "LABEL 3") top_panel.insert_item(item, 0) test.gui_loop(0.1)