def __init__(self, control: BaseWrapper): self._panel = control self._table = find_control(control, "Tree", "DataView") self._refresh_button = find_control(control, "Button", "Refresh", raise_on_failure=False) self._filter = find_control(control, "Edit", "Filter")
def _execute(self): self.find_control("TabItem", "Bottom-Up").click_input() logging.info('Switched to Bottom-Up tab') tree_view_table = Table( find_control(self.find_control('Group', 'bottomUpTab'), 'Tree')) logging.info('Counting rows of the bottom-up view...') if tree_view_table.get_row_count() < 10: raise RuntimeError('Less than 10 rows in the bottom-up view') first_row_tree_item = tree_view_table.get_item_at(0, 0) if first_row_tree_item.window_text() != 'ioctl': raise RuntimeError( 'First item of the bottom-up view is not "ioctl"') logging.info('Verified that first item is "ioctl"') first_row_tree_item.double_click_input() logging.info('Expanded the first item') second_row_tree_item = tree_view_table.get_item_at(1, 0) if not second_row_tree_item.window_text().startswith('drm'): raise RuntimeError( 'First child of the first item ("ioctl") ' 'of the bottom-up view doesn\'t start with "drm"') logging.info( 'Verified that first child of the first item starts with "drm"')
def _execute(self): self.find_control("TabItem", "Bottom-Up").click_input() logging.info('Switched to Bottom-Up tab') # main_wnd.TreeView.children(control_type='TreeItem') returns # every cell in the bottom-up view, in order by row and then column. # It can take a few seconds. logging.info('Listing items of the bottom-up view...') tree_view = find_control(self.find_control('Group', 'bottomUpTab'), 'Tree') tree_items = tree_view.children(control_type='TreeItem') BOTTOM_UP_ROW_CELL_COUNT = 5 row_count = len(tree_items) / BOTTOM_UP_ROW_CELL_COUNT if row_count < 10: raise RuntimeError('Less than 10 rows in the bottom-up view') if tree_items[0].window_text() != 'ioctl': raise RuntimeError( 'First item of the bottom-up view is not "ioctl"') logging.info('Verified that first item is "ioctl"') tree_items[0].double_click_input() logging.info('Expanded the first item') logging.info('Re-listing items of the bottom-up view...') tree_items = tree_view.children(control_type='TreeItem') if not tree_items[BOTTOM_UP_ROW_CELL_COUNT].window_text().startswith( 'drm'): raise RuntimeError( 'First child of the first item ("ioctl") ' 'of the bottom-up view doesn\'t start with "drm"') logging.info( 'Verified that first child of the first item starts with "drm"')
def _execute(self): self.find_control("TabItem", "Top-Down").click_input() logging.info('Switched to Top-Down tab') tree_view = find_control(self.find_control('Group', 'topDownTab'), 'Tree') # tree_view.children(control_type='TreeItem') returns # every cell in the top-down view, in order by row and then column. # It can take a few seconds. logging.info('Listing items of the top-down view...') tree_items = tree_view.children(control_type='TreeItem') TOP_DOWN_ROW_CELL_COUNT = 6 row_count_before_expansion = len(tree_items) / TOP_DOWN_ROW_CELL_COUNT if row_count_before_expansion < 3: raise RuntimeError('Less than 3 rows in the top-down view') if (not tree_items[0].window_text().startswith('hello_') or not tree_items[0].window_text().endswith(' (all threads)')): raise RuntimeError( 'First item of the top-down view is not "hello_* (all threads)"' ) logging.info('Verified that first item is "hello_* (all threads)"') if ((not tree_items[TOP_DOWN_ROW_CELL_COUNT].window_text().startswith( 'hello_') and not tree_items[TOP_DOWN_ROW_CELL_COUNT]. window_text().startswith('Ggp')) or not tree_items[TOP_DOWN_ROW_CELL_COUNT].window_text( ).endswith(']')): raise RuntimeError( 'Second item of the top-down view is not "hello_*]" nor "Ggp*]"' ) logging.info('Verified that second item is "hello_*]" or "Ggp*]"') tree_items[0].double_click_input() logging.info('Expanded the first item') logging.info('Re-listing items of the top-down view...') tree_items = tree_view.children(control_type='TreeItem') row_count_after_expansion = len(tree_items) / TOP_DOWN_ROW_CELL_COUNT if row_count_after_expansion < row_count_before_expansion + 2: raise RuntimeError( 'First item of the top-down view doesn\'t have at least two children' ) if (not ( (tree_items[TOP_DOWN_ROW_CELL_COUNT].window_text().endswith( 'clone') and tree_items[2 * TOP_DOWN_ROW_CELL_COUNT].window_text() == '_start') or (tree_items[TOP_DOWN_ROW_CELL_COUNT].window_text() == '_start') and tree_items[2 * TOP_DOWN_ROW_CELL_COUNT].window_text( ).endswith('clone'))): raise RuntimeError( 'Children of the first item of the top-down view ' 'are not "*clone" and "_start"') logging.info( 'Verified that children of the first item are "*clone" and "_start"' )
def _execute(self): wnd = self.e2e_test.top_window() # Find "Functions" tab and left and right tab bar tab_item = find_control(wnd, "TabItem", name="Functions") right_tab_bar = find_control( find_control(wnd, "Group", name="RightTabWidget"), "Tab") left_tab_bar = find_control( find_control(wnd, "Group", name="MainTabWidget"), "Tab") # Init tests left_tab_count = left_tab_bar.control_count() right_tab_count = right_tab_bar.control_count() tab_parent = tab_item.parent() self.expect_eq(tab_parent, right_tab_bar, "Functions tab is initialized in the right pane") # Move "Functions" tab to the left pane, check no. of tabs and if the tab is enabled logging.info( 'Moving "Functions" tab to the left pane (current tab count: %d)', right_tab_count) self.right_click_move_context(tab_item) self.expect_eq(right_tab_bar.control_count(), right_tab_count - 1, "1 tab removed from right pane") self.expect_eq(left_tab_bar.control_count(), left_tab_count + 1, "1 tab added to the left pane") tab_item = find_control(wnd, "TabItem", name="Functions") self.expect_eq(tab_item.parent(), left_tab_bar, "Functions tab is parented under the left pane") self.expect_true( find_control(wnd, "Group", auto_id_leaf="FunctionsTab").is_visible(), "Functions tab is visible") # Move back, check no. of tabs logging.info('Moving "Functions" tab back to the right pane') self.right_click_move_context(tab_item) self.expect_eq(right_tab_bar.control_count(), right_tab_count, "1 tab removed from left pane") self.expect_eq(left_tab_bar.control_count(), left_tab_count, "1 tab added to the right pane") tab_item = find_control(wnd, "TabItem", name="Functions") self.expect_eq(tab_item.parent(), right_tab_bar, "Functions tab is parented under the right pane") self.expect_true( find_control(wnd, "Group", auto_id_leaf="FunctionsTab").is_visible(), "Functions tab is visible")
def _find_and_close_error_dialog(top_window) -> str or None: window = find_control(top_window, 'Window', 'Error loading symbols', recurse=False, raise_on_failure=False) if window is None: return None error_message = find_control(window, 'Text').texts()[0] module_path_search_result = re.search('for module "(.+?)"', error_message) if not module_path_search_result: return None logging.info("Found error dialog with message {message}, closing.".format( message=error_message)) find_control(window, 'Button').click_input() return module_path_search_result[1]
def _execute(self, selection_tab: bool = False): tab = self._switch_to_tab(selection_tab) tree_view_table = Table(find_control(tab, 'Tree')) self._verify_columns(tree_view_table) self._verify_rows_when_tree_collapsed(tree_view_table) self._verify_rows_when_thread_expanded(tree_view_table) self._verify_rows_when_thread_recursively_expanded(tree_view_table) self._verify_rows_when_tree_expanded(tree_view_table) self._verify_rows_on_search(tab, tree_view_table)
def __init__(self, control: BaseWrapper): self._container = control self._name = control.texts()[0] self._title = find_control(control, 'TabItem') self._callstacks = find_control(control, 'Pane', 'Callstacks', raise_on_failure=False) self._thread_states = find_control(control, 'Pane', 'ThreadState', raise_on_failure=False) self._tracepoints = find_control(control, 'Pane', 'Tracepoints', raise_on_failure=False) self._timers = find_control(control, 'Pane', 'Timers', raise_on_failure=False)
def _show_symbols_and_functions_tabs(top_window): logging.info("Showing symbols tab") if flags.FLAGS.enable_ui_beta: find_control(top_window, "TabItem", "Symbols").click_input() else: find_control(top_window, "TabItem", "Home").click_input() find_control(top_window,"TabItem", "Functions").click_input()
def _show_and_get_symbol_location_ui(top_window): control = find_control(top_window, "Window", "Symbol Locations", raise_on_failure=False) # Early-out: Symbol locations window is already open if control is not None: return control # ... if we're still here, open the symbol locations window from the main menu find_control(top_window, "MenuItem", "Settings").click_input() find_control(top_window, "MenuItem", "Symbol Locations...").click_input() return find_control(top_window, "Window", "Symbol Locations")
def _execute(self): self.find_control("TabItem", "Top-Down").click_input() logging.info('Switched to Top-Down tab') tree_view_table = Table(find_control(self.find_control('Group', 'topDownTab'), 'Tree')) logging.info('Counting rows of the top-down view...') row_count_before_expansion = tree_view_table.get_row_count() if row_count_before_expansion < 3: raise RuntimeError('Less than 3 rows in the top-down view') first_row_tree_item = tree_view_table.get_item_at(0, 0) if (not first_row_tree_item.window_text().startswith('hello_') or not first_row_tree_item.window_text().endswith(' (all threads)')): raise RuntimeError('First item of the top-down view is not "hello_* (all threads)"') logging.info('Verified that first item is "hello_* (all threads)"') second_row_tree_item = tree_view_table.get_item_at(1, 0) if ((not second_row_tree_item.window_text().startswith('hello_') and not second_row_tree_item.window_text().startswith('Ggp')) or not second_row_tree_item.window_text().endswith(']')): raise RuntimeError('Second item of the top-down view is not "hello_*]" nor "Ggp*]"') logging.info('Verified that second item is "hello_*]" or "Ggp*]"') first_row_tree_item.double_click_input() logging.info('Expanded the first item') logging.info('Re-counting rows of the top-down view...') row_count_after_expansion = tree_view_table.get_row_count() if row_count_after_expansion < row_count_before_expansion + 2: raise RuntimeError( 'First item of the top-down view doesn\'t have at least two children') second_row_tree_item = tree_view_table.get_item_at(1, 0) third_row_tree_item = tree_view_table.get_item_at(2, 0) if (not ((second_row_tree_item.window_text().endswith('clone') and third_row_tree_item.window_text() == '_start') or (second_row_tree_item.window_text() == '_start') and third_row_tree_item.window_text().endswith('clone'))): raise RuntimeError('Children of the first item of the top-down view ' 'are not "*clone" and "_start"') logging.info('Verified that children of the first item are "*clone" and "_start"')
def _verify_rows_on_search(self, tab, tree_view_table): search_term = 'eventfd_write' logging.info("Searching bottom-up view for '{}'".format(search_term)) search_bar = find_control(parent=tab, control_type='Edit', name='filter') search_bar.set_focus() send_keys(search_term) time.sleep( 1 ) # The bottom-up view waits for the user to stop typing before searching. self._verify_row_count(tree_view_table, self.EXPECTED_LEAF_COUNT + 1) search_item_count = 0 for i in range(tree_view_table.get_row_count()): if tree_view_table.get_item_at(i, 0).window_text() == search_term: search_item_count += 1 expectations = [ "eventfd_write", "1.77% (28)", "", "100.00%", "libc-2.24.so", "0x7fe86eff5c30" ] for j in range(len(expectations)): if j in self.HIDDEN_COLUMNS: continue expectation = expectations[j] self.expect_eq( tree_view_table.get_item_at(i, j).window_text(), expectation, "Bottom-up view's cell ({}, {}) is '{}'".format( i, j, expectation)) self.expect_eq( search_item_count, 1, "Searching bottom-up view for '{}' produces one result".format( search_term)) logging.info( "Verified result of searching bottom-up view for '{}'".format( search_term))
def _verify_rows_on_search(self, tab, tree_view_table): search_term = 'fputs' logging.info("Searching top-down view for '{}'".format(search_term)) search_bar = find_control(parent=tab, control_type='Edit', name='filter') search_bar.set_focus() send_keys(search_term) time.sleep(1) # The top-down view waits for the user to stop typing before searching. self._verify_row_count(tree_view_table, 42) search_item_count = 0 for i in range(tree_view_table.get_row_count()): if tree_view_table.get_item_at(i, 0).window_text() == search_term: search_item_count += 1 expectations = [ "fputs", "0.06% (1)", "0.06% (1)", "100.00%", "libc-2.24.so", "0x7fe86ef70f90" ] for j in range(len(expectations)): expectation = expectations[j] self.expect_eq( tree_view_table.get_item_at(i, j).window_text(), expectation, "Top-down view's cell ({}, {}) is '{}'".format(i, j, expectation)) self.expect_eq(search_item_count, 2, "Searching top-down view for '{}' produces two results".format(search_term)) logging.info("Verified result of searching top-down view for '{}'".format(search_term))
def _show_symbols_and_functions_tabs(top_window): logging.info("Showing symbols tab") find_control(top_window, "TabItem", "Symbols").click_input()
def right_click_move_context(self, item): item.click_input(button='right') context_menu = self.e2e_test.application.window( best_match="TabBarContextMenu") find_control(context_menu, "MenuItem", name_contains="Move").click_input(button='left')
def __init__(self, control: BaseWrapper): self._container = control self._title = find_control(control, 'TabItem') self._content = find_control(control, 'Group')