Пример #1
0
    def test_is64bitprocess(self):
        "Make sure a 64-bit process detection returns correct results"
 
        if is_x64_OS():
            # Test a 32-bit app running on x64
            expected_is64bit = False
            if is_x64_Python():
                exe32bit = os.path.join(os.path.dirname(__file__),
                              r"..\..\apps\MFC_samples\RowList.exe")
                app = Application().start_(exe32bit, timeout=20)
                pid = app.RowListSampleApplication.ProcessID()
                res_is64bit = is64bitprocess(pid)
                try:
                    self.assertEquals(expected_is64bit, res_is64bit)
                finally:
                    # make sure to close an additional app we have opened
                    app.kill_()

                # setup expected for a 64-bit app on x64
                expected_is64bit = True
        else:
            # setup expected for a 32-bit app on x86
            expected_is64bit = False

        # test native Notepad app
        res_is64bit = is64bitprocess(self.app.UntitledNotepad.ProcessID())
        self.assertEquals(expected_is64bit, res_is64bit)
    def test_is64bitprocess(self):
        """Make sure a 64-bit process detection returns correct results"""
        if is_x64_OS():
            # Test a 32-bit app running on x64
            expected_is64bit = False
            if is_x64_Python():
                exe32bit = os.path.join(os.path.dirname(__file__),
                              r"..\..\apps\MFC_samples\RowList.exe")
                app = Application().start(exe32bit, timeout=20)
                pid = app.RowListSampleApplication.process_id()
                res_is64bit = is64bitprocess(pid)
                try:
                    self.assertEquals(expected_is64bit, res_is64bit)
                finally:
                    # make sure to close an additional app we have opened
                    app.kill_()

                # setup expected for a 64-bit app on x64
                expected_is64bit = True
        else:
            # setup expected for a 32-bit app on x86
            expected_is64bit = False

        # test native Notepad app
        res_is64bit = is64bitprocess(self.app.UntitledNotepad.process_id())
        self.assertEquals(expected_is64bit, res_is64bit)
Пример #3
0
 def testWaitCPUUsageLower(self):
     if is_x64_Python() != is_x64_OS():
         return None
     
     app = Application().Start(r'explorer.exe')
     WaitUntil(30, 0.5, lambda: len(findwindows.find_windows(active_only=True, class_name='CabinetWClass')) > 0)
     handle = findwindows.find_windows(active_only=True, class_name='CabinetWClass')[-1]
     window = WindowSpecification({'handle': handle, })
     explorer = Application().Connect(process=window.ProcessID())
     
     try:
         window.AddressBandRoot.ClickInput(double=True)
         window.Edit.SetEditText(r'Control Panel\Programs\Programs and Features')
         window.TypeKeys(r'{ENTER 2}', set_foreground=False)
         WaitUntil(30, 0.5, lambda: len(findwindows.find_windows(active_only=True, title='Programs and Features', class_name='CabinetWClass')) > 0)
         explorer.WaitCPUUsageLower(threshold=2.5, timeout=40, usage_interval=2)
         installed_programs = window.FolderView.Texts()[1:]
         programs_list = ','.join(installed_programs)
         if ('Microsoft' not in programs_list) and ('Python' not in programs_list):
             HwndWrapper.ImageGrab.grab().save(r'explorer_screenshot.jpg')
         HwndWrapper.ActionLogger().log('\ninstalled_programs:\n')
         for prog in installed_programs:
             HwndWrapper.ActionLogger().log(prog)
         self.assertEqual(('Microsoft' in programs_list) or ('Python' in programs_list), True)
     finally:
         window.Close(2.0)
Пример #4
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        # start the application
        self.app = Application()
        if is_x64_Python() or not is_x64_OS():
            self.app.start_(r"C:\Windows\System32\notepad.exe")
        else:
            self.app.start_(r"C:\Windows\SysWOW64\notepad.exe")

        # Get the old font
        self.app.UntitledNotepad.Wait('ready', 50)
        self.app.UntitledNotepad.MenuSelect("Format->Font...")
        self.app.Font.Wait("visible", 50)

        self.old_font = self.app.Font.FontComboBox.SelectedIndex()
        self.old_font_style = self.app.Font.FontStyleCombo.SelectedIndex()

        # ensure we have the correct settings for this test
        self.app.Font.FontStyleCombo.Select(0)
        self.app.Font.FontComboBox.Select("Lucida Console")
        self.app.Font.OK.Click()

        self.dlg = self.app.Window_(title='Untitled - Notepad', class_name='Notepad')
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
        self.dlg.edit.SetEditText("Here is some text\r\n and some more")
Пример #5
0
    def testClickVisibleIcon(self):
        """
        Test minimizing a sample app into the visible area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is disabled
        orig_hid_state = _toggle_notification_area_icons(
            show_all=True, debug_img="%s_01.jpg" % (self.id()))

        self.dlg.Minimize()
        self.dlg.WaitNot('active')

        # click in the visible area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=40)
        taskbar.ClickSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('active', timeout=40)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02.jpg" % (self.id()))
Пример #6
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        # start the application
        self.app = Application()
        if is_x64_Python() or not is_x64_OS():
            self.app.start_(r"C:\Windows\System32\notepad.exe")
        else:
            self.app.start_(r"C:\Windows\SysWOW64\notepad.exe")

        # Get the old font
        self.app.UntitledNotepad.MenuSelect("Format->Font")

        self.old_font = self.app.Font.FontComboBox.SelectedIndex()
        self.old_font_style = self.app.Font.FontStyleCombo.SelectedIndex()

        # ensure we have the correct settings for this test
        self.app.Font.FontStyleCombo.Select(0)
        self.app.Font.FontComboBox.Select("Lucida Console")
        self.app.Font.OK.Click()

        self.dlg = self.app.Window_(title='Untitled - Notepad',
                                    class_name='Notepad')
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
        self.dlg.edit.SetEditText("Here is some text\r\n and some more")
Пример #7
0
    def testClickVisibleIcon(self):
        """
        Test minimizing a sample app into the visible area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is disabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=True,
                debug_img="%s_01" % (self.id())
                )

        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # click in the visible area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=self.tm)
        taskbar.ClickSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('active', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))
Пример #8
0
 def setUp(self):
     """Start the application set some data and ensure the application
     is in the state we want it."""
     self.prev_warn = warnings.showwarning
     def no_warnings(*args, **kwargs): pass
     warnings.showwarning = no_warnings
     if is_x64_Python() or not is_x64_OS():
         self.notepad_subpath = r"system32\notepad.exe"
     else:
         self.notepad_subpath = r"SysWOW64\notepad.exe"
 def setUp(self):
     """Start the application set some data and ensure the application
     is in the state we want it."""
     self.prev_warn = warnings.showwarning
     def no_warnings(*args, **kwargs): pass
     warnings.showwarning = no_warnings
     if is_x64_Python() or not is_x64_OS():
         self.notepad_subpath = r"system32\notepad.exe"
     else:
         self.notepad_subpath = r"SysWOW64\notepad.exe"
Пример #10
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        self.app = Application()

        if is_x64_Python() or not is_x64_OS():
            self.app.start(r"C:\Windows\System32\calc.exe")
        else:
            self.app.start(r"C:\Windows\SysWOW64\calc.exe")
        self.calc = self.app.Calculator
        self.calc.MenuSelect("View->Scientific")
Пример #11
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        # start the application
        self.app = Application()
        if is_x64_Python() or not is_x64_OS():
            self.app.start(r"C:\Windows\System32\notepad.exe")
        else:
            self.app.start(r"C:\Windows\SysWOW64\notepad.exe")

        self.dlg = self.app.UntitledNotepad
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
Пример #12
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        # start the application
        self.app = Application()
        if is_x64_Python() or not is_x64_OS():
            self.app.start_(r"C:\Windows\System32\notepad.exe")
        else:
            self.app.start_(r"C:\Windows\SysWOW64\notepad.exe")

        self.dlg = self.app.UntitledNotepad
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
 def testStartWarning3264(self):
     if not is_x64_OS():
         self.defaultTestResult()
         return
     
     warnings.filterwarnings('always', category=UserWarning, append=True)
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         app = Application.start(self.sample_exe)
         app.kill_()
         assert len(w) >= 1
         assert issubclass(w[-1].category, UserWarning)
         assert "64-bit" in str(w[-1].message)
Пример #14
0
    def testStartWarning3264(self):
        if not is_x64_OS():
            self.defaultTestResult()
            return

        warnings.filterwarnings('always', category=UserWarning, append=True)
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            app = Application().start(self.sample_exe_inverted_bitness)
            app.kill_()
            assert len(w) >= 1
            assert issubclass(w[-1].category, UserWarning)
            assert "64-bit" in str(w[-1].message)
Пример #15
0
    def test_wait_cpu_usage_lower(self):
        """Test that wait_cpu_usage_lower() works correctly"""
        if is_x64_Python() != is_x64_OS():
            return None

        Application().Start(r'explorer.exe')

        def _cabinetwclass_exist():
            "Verify if at least one active 'CabinetWClass' window is created"
            l = findwindows.find_elements(active_only=True,
                                          class_name='CabinetWClass')
            return (len(l) > 0)

        WaitUntil(40, 0.5, _cabinetwclass_exist)
        handle = findwindows.find_elements(
            active_only=True, class_name='CabinetWClass')[-1].handle
        window = WindowSpecification({
            'handle': handle,
            'backend': 'win32',
        })
        explorer = Application().Connect(process=window.process_id())

        try:
            explorer.WaitCPUUsageLower(threshold=1.5,
                                       timeout=60,
                                       usage_interval=2)
            window.AddressBandRoot.ClickInput()
            window.TypeKeys(r'Control Panel\Programs\Programs and Features',
                            with_spaces=True,
                            set_foreground=True)
            window.TypeKeys(r'{ENTER}', set_foreground=False)
            WaitUntil(
                40, 0.5, lambda: len(
                    findwindows.find_elements(active_only=True,
                                              title='Programs and Features',
                                              class_name='CabinetWClass')) > 0)
            explorer.WaitCPUUsageLower(threshold=1.5,
                                       timeout=60,
                                       usage_interval=2)
            installed_programs = window.FolderView.texts()[1:]
            programs_list = ','.join(installed_programs)
            if ('Microsoft' not in programs_list) and ('Python'
                                                       not in programs_list):
                hwndwrapper.ImageGrab.grab().save(r'explorer_screenshot.jpg')
                hwndwrapper.ActionLogger().log('\ninstalled_programs:\n')
                for prog in installed_programs:
                    hwndwrapper.ActionLogger().log(prog)
            self.assertEqual(('Microsoft' in programs_list)
                             or ('Python' in programs_list), True)
        finally:
            window.Close(2.0)
Пример #16
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        # start the application
        self.app = Application()
        if is_x64_Python() or not is_x64_OS():
            self.app.start_(r"C:\Windows\System32\calc.exe")
        else:
            self.app.start_(r"C:\Windows\SysWOW64\calc.exe")

        self.dlg = self.app.Calculator
        self.dlg.MenuSelect('View->Scientific\tAlt+2')
        self.ctrl = HwndWrapper(self.dlg.Button2.handle)  # Backspace
Пример #17
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        self.app = Application()

        if is_x64_Python() or not is_x64_OS():
            self.app.start(r"C:\Windows\System32\calc.exe")
        else:
            self.app.start(r"C:\Windows\SysWOW64\calc.exe")
        self.calc = self.app.CalcFrame

        # write out the XML so that we can read it in later
        self.app.Calculator.WriteToXML("ref_controls.xml")
Пример #18
0
    def setUp(self):
        """Start the application set some data and ensure the application
        is in the state we want it."""

        # start the application
        self.app = Application()
        if is_x64_Python() or not is_x64_OS():
            self.app.start(r"C:\Windows\System32\calc.exe")
        else:
            self.app.start(r"C:\Windows\SysWOW64\calc.exe")

        self.dlg = self.app.Calculator
        self.dlg.MenuSelect('View->Scientific\tAlt+2')
        self.ctrl = HwndWrapper(self.dlg.Button2.handle) # Backspace
Пример #19
0
def is64bitprocess(process_id):
    """Return True if the specified process is a 64-bit process on x64
       and False if it is only a 32-bit process running under Wow64.
       Always return False for x86"""

    from pywinauto.sysinfo import is_x64_OS
    is32 = True
    if is_x64_OS():
        import win32process, win32api, win32con
        phndl = win32api.OpenProcess(win32con.MAXIMUM_ALLOWED, 0, process_id)
        if phndl:
            is32 = win32process.IsWow64Process(phndl)
            #print("is64bitprocess, is32: %d, procid: %d" % (is32, process_id))

    return (not is32)
Пример #20
0
def is64bitprocess(process_id):
    """Return True if the specified process is a 64-bit process on x64
       and False if it is only a 32-bit process running under Wow64.
       Always return False for x86"""

    from pywinauto.sysinfo import is_x64_OS
    is32 = True
    if is_x64_OS():
        import win32process, win32api
        phndl = win32api.OpenProcess(0x400, 0, process_id)
        if phndl:
          is32 = win32process.IsWow64Process(phndl)
          #print("is64bitprocess, is32: %d, procid: %d" % (is32, process_id))
        
    return (not is32)
Пример #21
0
        def setUp(self):
            """Start the application set some data and ensure the application
            is in the state we want it."""

            # TODO: re-write the whole test
            self.app = Application(backend="native")
            if is_x64_Python() or not is_x64_OS():
                self.app.start(r"C:\Windows\System32\calc.exe")
            else:
                self.app.start(r"C:\Windows\SysWOW64\calc.exe")
            
            self.dlg = self.app.Calculator
            self.handle = self.dlg.handle
            self.dlg.MenuSelect('View->Scientific\tAlt+2')
            self.ctrl = UIAElementInfo(self.dlg.handle)
Пример #22
0
        def setUp(self):
            """Start the application set some data and ensure the application
            is in the state we want it."""

            # TODO: re-write the whole test
            self.app = Application(backend="native")
            if is_x64_Python() or not is_x64_OS():
                self.app.start(r"C:\Windows\System32\calc.exe")
            else:
                self.app.start(r"C:\Windows\SysWOW64\calc.exe")

            self.dlg = self.app.Calculator
            self.handle = self.dlg.handle
            self.dlg.MenuSelect('View->Scientific\tAlt+2')
            self.ctrl = UIAElementInfo(self.dlg.handle)
Пример #23
0
    def testConnectWarning3264(self):
        if not is_x64_OS():
            self.defaultTestResult()
            return

        app = Application().start(self.sample_exe_inverted_bitness)
        # Appveyor misteries...
        self.assertEqual(app.is_process_running(), True)

        with mock.patch("warnings.warn") as mockWarn:
            Application().connect(process=app.process)
            app.kill_()
            args, kw = mockWarn.call_args
            assert len(args) == 2
            assert "64-bit" in args[0]
            assert args[1].__name__ == 'UserWarning'
Пример #24
0
    def testConnect_path(self):
        "Test that connect_() works with a path"
        app1 = Application()
        app1.start(_notepad_exe())

        app_conn = Application()
        app_conn.connect(path=self.notepad_subpath)
        self.assertEqual(app1.process, app_conn.process)

        app_conn = Application()
        if is_x64_Python() or not is_x64_OS():
            app_conn.connect(path=r"c:\windows\system32\notepad.exe")
        else:
            app_conn.connect(path=r"c:\windows\syswow64\notepad.exe")
        self.assertEqual(app1.process, app_conn.process)

        app_conn.UntitledNotepad.MenuSelect('File->Exit')
    def testConnect_path(self):
        "Test that connect_() works with a path"
        app1 = Application()
        app1.start_(_notepad_exe())

        app_conn = Application()
        app_conn.connect_(path = self.notepad_subpath)
        self.assertEqual(app1.process, app_conn.process)

        app_conn = Application()
        if is_x64_Python() or not is_x64_OS():
            app_conn.connect_(path = r"c:\windows\system32\notepad.exe")
        else:
            app_conn.connect_(path = r"c:\windows\syswow64\notepad.exe")
        self.assertEqual(app1.process, app_conn.process)

        app_conn.UntitledNotepad.MenuSelect('File->Exit')
Пример #26
0
    def testClickVisibleIcon(self):
        """
        Test minimizing a sample app into the visible area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is disabled
        orig_hid_state = _toggle_notification_area_icons(
            show_all=True,
            debug_img="%s_01" % (self.id())
        )

        self.dlg.minimize()
        _wait_minimized(self.dlg)

        menu_window = [None]

        # Click in the visible area and wait for a popup menu
        def _show_popup_menu():
            taskbar.explorer_app.wait_cpu_usage_lower(threshold=5, timeout=self.tm)
            taskbar.RightClickSystemTrayIcon('MFCTrayDemo')
            menu = self.app.top_window().children()[0]
            res = isinstance(menu, ToolbarWrapper) and menu.is_visible()
            menu_window[0] = menu
            return res

        wait_until(self.tm, _retry_interval, _show_popup_menu)
        menu_window[0].menu_bar_click_input("#2", self.app)
        popup_window = self.app.top_window()
        hdl = self.dlg.popup_window()
        self.assertEqual(popup_window.handle, hdl)

        taskbar.ClickSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.wait('active', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))
Пример #27
0
    def testClickHiddenIcon(self):
        """
        Test minimizing a sample app into the hidden area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is enabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=False,
                debug_img="%s_01" % (self.id())
                )

        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # Run one more instance of the sample app
        # hopefully one of the icons moves into the hidden area
        self.app2 = Application()
        self.app2.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"))
        dlg2 = self.app2.TrayMenu
        dlg2.Wait('visible', timeout=self.tm)
        dlg2.Minimize()
        _wait_minimized(dlg2)

        # Click in the hidden area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=40)
        taskbar.ClickHiddenSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('visible', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))

        dlg2.SendMessage(win32defines.WM_CLOSE)
        self.app2 = None
Пример #28
0
    def test_connect_path(self):
        """Test that connect_() works with a path"""
        app1 = Application()
        app1.start(_notepad_exe())

        app_conn = Application()
        app_conn.connect(path=self.notepad_subpath)
        self.assertEqual(app1.process, app_conn.process)

        app_conn = Application()
        if is_x64_Python() or not is_x64_OS():
            app_conn.connect(path=r"c:\windows\system32\notepad.exe")
        else:
            app_conn.connect(path=r"c:\windows\syswow64\notepad.exe")
        self.assertEqual(app1.process, app_conn.process)

        accessible_modules = process_get_modules()
        accessible_process_names = [os.path.basename(name.lower()) for process, name, cmdline in accessible_modules]
        self.assertEquals('notepad.exe' in accessible_process_names, True)

        app_conn.UntitledNotepad.MenuSelect('File->Exit')
Пример #29
0
    def test_connect_path(self):
        """Test that connect_() works with a path"""
        app1 = Application()
        app1.start(_notepad_exe())

        app_conn = Application()
        app_conn.connect(path=self.notepad_subpath)
        self.assertEqual(app1.process, app_conn.process)

        app_conn = Application()
        if is_x64_Python() or not is_x64_OS():
            app_conn.connect(path=r"c:\windows\system32\notepad.exe")
        else:
            app_conn.connect(path=r"c:\windows\syswow64\notepad.exe")
        self.assertEqual(app1.process, app_conn.process)

        accessible_modules = process_get_modules()
        accessible_process_names = [os.path.basename(name.lower()) for process, name, cmdline in accessible_modules]
        self.assertEquals('notepad.exe' in accessible_process_names, True)

        app_conn.UntitledNotepad.MenuSelect('File->Exit')
Пример #30
0
    def testClickHiddenIcon(self):
        """
        Test minimizing a sample app into the hidden area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is enabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=False,
                debug_img="%s_01" % (self.id())
                )

        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # Run one more instance of the sample app
        # hopefully one of the icons moves into the hidden area
        app2 = Application()
        app2.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"))
        dlg2 = app2.top_window_()
        dlg2.Wait('visible', timeout=self.tm)
        dlg2.Minimize()
        _wait_minimized(dlg2)

        # Click in the hidden area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=40)
        taskbar.ClickHiddenSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('visible', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))

        dlg2.SendMessage(win32defines.WM_CLOSE)
Пример #31
0
    def testClickVisibleIcon(self):
        """
        Test minimizing a sample app into the visible area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is disabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=True,
                debug_img="%s_01" % (self.id())
                )

        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # click in the visible area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=self.tm)
        taskbar.RightClickSystemTrayIcon('MFCTrayDemo')

        # verify PopupWindow method
        menu_window = self.app.top_window_().Children()[0]
        WaitUntil(self.tm, _retry_interval, menu_window.IsVisible)
        menu_window.MenuBarClickInput("#2", self.app)
        popup_window = self.app.top_window_()
        hdl = self.dlg.PopupWindow()
        self.assertEquals(popup_window.handle, hdl)

        taskbar.ClickSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('active', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))
Пример #32
0
    def test_wait_cpu_usage_lower(self):
        """Test that wait_cpu_usage_lower() works correctly"""
        if is_x64_Python() != is_x64_OS():
            return None
        
        app = Application().Start(r'explorer.exe')
        
        def _cabinetwclass_exist():
            "Verify if at least one active 'CabinetWClass' window is created"
            l = findwindows.find_elements(active_only = True, class_name = 'CabinetWClass')
            return (len(l) > 0)

        WaitUntil(40, 0.5, _cabinetwclass_exist)
        handle = findwindows.find_elements(active_only = True, class_name = 'CabinetWClass')[-1].handle
        window = WindowSpecification({'handle': handle, 'backend': 'native', })
        explorer = Application().Connect(process = window.process_id())
        
        try:
            explorer.WaitCPUUsageLower(threshold = 1.5, timeout = 60, usage_interval = 2)
            window.AddressBandRoot.ClickInput()
            window.TypeKeys(r'Control Panel\Programs\Programs and Features', with_spaces=True, set_foreground=True)
            window.TypeKeys(r'{ENTER}', set_foreground = False)
            WaitUntil(40, 0.5, lambda: len(findwindows.find_elements(active_only = True,
                                                                     title = 'Programs and Features',
                                                                     class_name='CabinetWClass')) > 0)
            explorer.WaitCPUUsageLower(threshold = 1.5, timeout = 60, usage_interval = 2)
            installed_programs = window.FolderView.texts()[1:]
            programs_list = ','.join(installed_programs)
            if ('Microsoft' not in programs_list) and ('Python' not in programs_list):
                HwndWrapper.ImageGrab.grab().save(r'explorer_screenshot.jpg')
                HwndWrapper.ActionLogger().log('\ninstalled_programs:\n')
                for prog in installed_programs:
                    HwndWrapper.ActionLogger().log(prog)
            self.assertEqual(('Microsoft' in programs_list) or ('Python' in programs_list), True)
        finally:
            window.Close(2.0)
Пример #33
0
def _notepad_exe():
    if is_x64_Python() or not is_x64_OS():
        return r"C:\Windows\System32\notepad.exe"
    else:
        return r"C:\Windows\SysWOW64\notepad.exe"
Пример #34
0
def _notepad_exe():
    if is_x64_Python() or not is_x64_OS():
        return r"C:\Windows\System32\notepad.exe"
    else:
        return r"C:\Windows\SysWOW64\notepad.exe"