示例#1
0
def main(argv):
    orbit_testing.wait_for_orbit()
    application = Application(backend='uia').connect(title_re='orbitprofiler')
    orbit_testing.connect_to_gamelet(application)
    orbit_testing.select_process(application, 'hello_')
    orbit_testing.load_symbols(application, 'hello_')
    orbit_testing.hook_function(application, 'DrawFrame')
    orbit_testing.focus_on_capture_window(application)
    orbit_testing.capture(application, 5)

    main_wnd = application.window(title_re='orbitprofiler', found_index=0)
    # Find 'DrawFrame' in the live tab and create a frame track.
    children = main_wnd.TreeView.children()
    for i in range(len(children)):
        if 'DrawFrame' in children[i].window_text():
            children[i].click_input(button='right')
            main_wnd.child_window(title='Enable frame track(s)',
                                  control_type="MenuItem").click_input()

    # Since the frame track is only a visualization and only affects the
    # OpenGL rendered capture window, there is currently no way to verify
    # automatically that the frame track was created correctly.

    main_wnd.CloseButton.click_input()
    logging.info('Closed Orbit.')
示例#2
0
def main(argv):
    orbit_testing.wait_for_orbit()
    application = Application(backend='uia').connect(title_re='orbitprofiler')
    orbit_testing.connect_to_gamelet(application)
    orbit_testing.select_process(application, 'hello_')
    orbit_testing.load_symbols(application, 'hello_')
    orbit_testing.hook_function(application, 'DrawFrame')
    orbit_testing.focus_on_capture_window(application)
    orbit_testing.capture(application, 5)

    main_wnd = application.window(title_re='orbitprofiler', found_index=0)

    # Adding an iterator adds three new buttons and we use this knowledge to
    # verify that an iterator was added correctly. It seems other widgets like
    # the label are not well represented by pywinauto.
    BUTTONS_PER_ITERATOR = 3
    count_all_buttons_before = len(main_wnd.descendants(control_type='Button'))

    # Find 'DrawFrame' in the live tab and add an iterator
    children = main_wnd.TreeView.children()
    for i in range(len(children)):
        if 'DrawFrame' in children[i].window_text():
            children[i].click_input(button='right')
            main_wnd.child_window(title='Add iterator(s)',
                                  control_type="MenuItem").click_input()

    count_all_buttons_after = len(main_wnd.descendants(control_type='Button'))
    if count_all_buttons_before + BUTTONS_PER_ITERATOR != count_all_buttons_after:
        raise RuntimeError('Iterator not correctly added')

    main_wnd.CloseButton.click_input()
    logging.info('Closed Orbit.')
示例#3
0
def main(argv):
    orbit_testing.wait_for_orbit()
    application = Application(backend='uia').connect(title_re='orbitprofiler')
    orbit_testing.connect_to_gamelet(application)
    orbit_testing.select_process(application, 'hello_')
    orbit_testing.focus_on_capture_window(application)
    orbit_testing.capture(application, 5)

    main_wnd = application.window(title_re='orbitprofiler', found_index=0)
    main_wnd.child_window(title="Bottom-Up").click_input()
    logging.info('Switched to Bottom-Up tab')

    # Now that the "Bottom-Up" tab is selected,
    # main_wnd.TreeView is the QTreeView of the bottom-up view.
    # 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_items = main_wnd.TreeView.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 = main_wnd.TreeView.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"')

    main_wnd.CloseButton.click_input()
    logging.info('Closed Orbit.')
示例#4
0
def main(argv):
    orbit_testing.wait_for_orbit()
    application = Application(backend='uia').connect(title_re='orbitprofiler')
    orbit_testing.connect_to_gamelet(application)
    orbit_testing.select_process(application, 'hello_')
    orbit_testing.focus_on_capture_window(application)
    orbit_testing.capture(application, 5)

    main_wnd = application.window(title_re='orbitprofiler', found_index=0)
    main_wnd.child_window(title="Top-Down").click_input()
    logging.info('Switched to Top-Down tab')

    # Now that the "Top-Down" tab is selected,
    # main_wnd.TreeView is the QTreeView of the top-down view.
    # main_wnd.TreeView.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 = main_wnd.TreeView.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 = main_wnd.TreeView.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 exactly 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"')

    main_wnd.CloseButton.click_input()
    logging.info('Closed Orbit.')
示例#5
0
def main(argv):
    orbit_testing.wait_for_orbit()
    application = Application(backend='uia').connect(title_re='orbitprofiler')
    orbit_testing.connect_to_gamelet(application)
    orbit_testing.select_process(application, 'hello_')

    # Load the presets.
    main_wnd = application.window(title_re='orbitprofiler', found_index=0)
    main_wnd.PresetsTreeView2.draw_frame_in_hello_ggp_1_52.click_input(
        button='right')
    main_wnd.LoadPreset.click_input()
    logging.info('Loaded Preset DrawFrame')
    main_wnd.PresetsTreeView2.ggp_issue_frame_token_in_hello_ggp_1_52.click_input(
        button='right')
    main_wnd.LoadPreset.click_input()
    logging.info('Loaded Preset GgpIssueFrameToken.')

    # Check that the check mark in front of the hooked function is there.
    # TreeView is the panel that contains all the function names.
    main_wnd.FunctionsTabItem.click_input()
    children = main_wnd.TreeView.children()
    found_draw_frame = False
    found_ggp_issue_frame_token = False
    for i in range(len(children)):
        if 'DrawFrame' in children[i].window_text():
            found_draw_frame = True
            if u'\u2713' not in children[i - 1].window_text():
                raise RuntimeError(
                    'Function DrawFrame was not hooked by appling preset.' +
                    str(children[i - 1].window_text()))
            else:
                logging.info('Verified DrawFrame was hooked.')
        if 'GgpIssueFrameToken' in children[i].window_text():
            found_ggp_issue_frame_token = True
            if u'\u2713' not in children[i - 1].window_text():
                raise RuntimeError(
                    'Function GgpIssueFrameToken was not hooked by appling preset.'
                )
            else:
                logging.info('Verified GgpIssueFrameToken was hooked.')

    if not found_draw_frame:
        raise RuntimeError('Function DrawFrame was not found in the binary.')
    if not found_ggp_issue_frame_token:
        raise RuntimeError(
            'Function GgpIssueFrameToken was not found in the binary.')

    orbit_testing.focus_on_capture_window(application)
    orbit_testing.capture(application, 5)

    # Check the output in the live tab. DrawFrames should have been called ~300
    # times (60 Hz * 5 seconds).
    children = main_wnd.TreeView.children()
    found_draw_frame = False
    found_ggp_issue_frame_token = False
    for i in range(len(children)):
        if 'DrawFrame' in children[i].window_text():
            found_draw_frame = True
            num = int(children[i + 1].window_text())
            if num < 30 or num > 3000:
                raise RuntimeError('Wrong number of calls to "DrawFrame": ' +
                                   str(num))
            else:
                logging.info('Verified number of calls to "DrawFrame".')
        if 'GgpIssueFrameToken' in children[i].window_text():
            found_ggp_issue_frame_token = True
            num = int(children[i + 1].window_text())
            if num < 30 or num > 3000:
                raise RuntimeError(
                    'Wrong number of calls to "GgpIssueFrameToken": ' +
                    str(num))
            else:
                logging.info(
                    'Verified number of calls to "GgpIssueFrameToken".')

    if not found_draw_frame:
        raise RuntimeError('Function DrawFrame was not found in the binary.')
    if not found_ggp_issue_frame_token:
        raise RuntimeError(
            'Function GgpIssueFrameToken was not found in the binary.')

    main_wnd.CloseButton.click_input()
    logging.info('Closed Orbit.')