def _execute(self, expected_name: str): """ :param expected_name: The exact name of the track to be collapsed. "*" is allowed as placeholder. """ assert (expected_name != "") tracks = self._find_tracks(expected_name) self.expect_true(len(tracks) == 1, 'Found track {}'.format(expected_name)) track = Track(tracks[0]) prev_height = track.container.rectangle().height() triangle_toggle = track.triangle_toggle # TODO(b/184237564): Very short mouse clicks (within one frame) will be ignored. Thus we need expand # the duration of the click explicitly. triangle_toggle.click_input(button_up=False) time.sleep(0.1) triangle_toggle.click_input(button_down=False) post_height = track.container.rectangle().height() self._verify_height(prev_height, post_height, expected_name)
def _execute(self, track_index: int = 0, check_selection_before: bool = False, expect_failure: bool = False): """ :param track_index: Index of the track to select :param check_selection_before: If True, verifies that this track was not selected before :param expect_failure: If True, it is expected that the track in question is NOT selected after executing this """ track = Track(self._find_tracks()[track_index]) if check_selection_before: self.expect_true(not track.container.has_keyboard_focus(), "Track is not selected") logging.info("Selecting track with index %s", track_index) track.title.click_input() if expect_failure: self.expect_true(not track.container.has_keyboard_focus(), "Track is not selected") else: self.expect_true(track.container.has_keyboard_focus(), "Track is selected")
def _execute(self, track_name_filter: str): tracks = self._find_tracks(track_name_filter) self.expect_true( len(tracks) == 1, 'Found exactly one track matching "{}"'.format(track_name_filter)) track = Track(tracks[0]) self.expect_true(track.callstacks is not None, 'Track "{}" has callstacks pane'.format(track.name)) logging.info('Selecting all visible callstacks in track "{}"'.format(track.name)) callstacks = track.callstacks rect = callstacks.rectangle() callstacks.drag_mouse_input(src=(rect.left, rect.top + 5), dst=(rect.right, rect.top + 5)) self.expect_true( self.find_control('TabItem', 'Sampling (selection)').is_enabled(), "'Sampling (selection)' tab is enabled") self.expect_true( self.find_control('TabItem', 'Top-Down (selection)').is_enabled(), "'Top-Down (selection)' tab is enabled") self.expect_true( self.find_control('TabItem', 'Bottom-Up (selection)').is_enabled(), "'Bottom-Up (selection)' tab is enabled") logging.info("Verified that '(selection)' tabs are enabled")
def _execute(self, track_index: int = 0, new_index: int = 0, expected_new_index: int = None): """ :param track_index: Track index (before dragging) to move :param new_index: New index the track should be moved to :param expected_new_index: Optional - Expected index of the track after moving. If None, it is expected that the track will be at position <new_index> after execution. """ if expected_new_index is None: expected_new_index = new_index # Drag 1 px above the target track index if moving up, or 1 px below if moving down tracks = self._find_tracks() rect = tracks[new_index].rectangle() track_count = len(tracks) if track_index % track_count >= new_index % track_count: new_y = rect.top - 1 else: new_y = rect.bottom + 1 track = Track(tracks[track_index]) mouse_x = track.title.rectangle().left + 5 logging.info( "Moving track '{}' from index {} to y={} (expected new index: {})". format(track.container.texts()[0], track_index, new_y, expected_new_index)) track.title.drag_mouse_input((mouse_x, new_y + 5)) index = self._find_tracks().index(track.container) self.expect_eq( index, expected_new_index % track_count, "Expected track index {} after reordering, got {}".format( expected_new_index, index))