class StaticTestCases(unittest.TestCase): """Unit tests for the StaticWrapper class""" def setUp(self): """Start the sample application. Open a tab with ownerdraw button.""" # start the application self.app = Application().Start(os.path.join(mfc_samples_folder, u"RebarTest.exe")) # open the Help dailog self.app.active_().TypeKeys('%h{ENTER}') def tearDown(self): """Close the application after tests""" self.app.kill_() def test_NeedsImageProp(self): """test a regular static has no the image property""" active_window = self.app.active_() self.assertEquals(active_window.Static2._NeedsImageProp, False) self.assertNotIn('Image', active_window.Static2.GetProperties()) def test_NeedsImageProp_ownerdraw(self): """test whether an image needs to be saved with the properties""" active_window = self.app.active_() self.assertEquals(active_window.Static._NeedsImageProp, True) self.assertIn('Image', active_window.Static.GetProperties())
class ButtonOwnerdrawTestCases(unittest.TestCase): """Unit tests for the ButtonWrapper(ownerdraw button)""" def setUp(self): """Start the sample application. Open a tab with ownerdraw button.""" # start the application self.app = Application().Start(os.path.join(mfc_samples_folder, u"CmnCtrl3.exe")) # open the needed tab self.app.active_().TabControl.Select(1) def tearDown(self): """Close the application after tests""" self.app.kill_() def test_NeedsImageProp(self): """test whether an image needs to be saved with the properties""" active_window = self.app.active_() self.assertEquals(active_window.Button2._NeedsImageProp, True) self.assertIn('Image', active_window.Button2.GetProperties())
class StaticTestCases(unittest.TestCase): """Unit tests for the StaticWrapper class""" def setUp(self): """Start the sample application. Open a tab with ownerdraw button.""" Timings.defaults() self.app = Application().Start( os.path.join(mfc_samples_folder, u"RebarTest.exe")) # open the Help dailog self.app.active_().type_keys('%h{ENTER}') def tearDown(self): """Close the application after tests""" self.app.kill_() def test_NeedsImageProp(self): """test a regular static has no the image property""" active_window = self.app.active_() self.assertEquals(active_window.Static2._needs_image_prop, False) self.assertEquals('image' in active_window.Static2.GetProperties(), False) #self.assertNotIn('image', active_window.Static2.GetProperties()) # assertIn and assertNotIn are not supported in Python 2.6 def test_NeedsImageProp_ownerdraw(self): """test whether an image needs to be saved with the properties""" active_window = self.app.active_() self.assertEquals(active_window.Static._needs_image_prop, True) self.assertEquals('image' in active_window.Static.GetProperties(), True)
class ButtonOwnerdrawTestCases(unittest.TestCase): """Unit tests for the ButtonWrapper(ownerdraw button)""" def setUp(self): """Start the sample application. Open a tab with ownerdraw button.""" _set_timings_fast() self.app = Application().Start(os.path.join(mfc_samples_folder, u"CmnCtrl3.exe")) # open the needed tab self.app.active_().TabControl.Select(1) def tearDown(self): """Close the application after tests""" self.app.kill_() def test_NeedsImageProp(self): """test whether an image needs to be saved with the properties""" active_window = self.app.active_() self.assertEquals(active_window.Button2._needs_image_prop, True) self.assertEquals('image' in active_window.Button2.GetProperties(), True)
def test_active_window(self): """Test that active_() works correctly""" app = Application() self.assertRaises(AppNotConnected, app.active_) self.assertRaises(AppNotConnected, app.is64bit) app.start(_notepad_exe()) app.UntitledNotepad.Wait('ready') self.assertEqual(app.active_().handle, app.UntitledNotepad.handle) app.UntitledNotepad.MenuSelect("File->Exit") app.UntitledNotepad.WaitNot('exists') self.assertRaises(RuntimeError, app.active_)