def test_run_hello_world_in_xvfb(self): self.xvfb_server.start_sync() self.assertTrue(self.xvfb_server.is_running()) # This should be completely black empty_scr_0 = self.xvfb_server.get_screenshot() self.assertTrue(is_black_image(Image.open(empty_scr_0))) # Start the hello world in the xvfb run_result = self.xvfb_server.run_x_process(self.X_TEST_COMMAND, block=False) self.assertTrue(run_result) # Let the window appear in the xvfb, note that block is False above time.sleep(1) # In screen 0 there should be a window, the one I started in the # previous step. screen_0 = self.xvfb_server.get_screenshot() self.assertFalse(is_black_image(Image.open(screen_0)))
def test_get_screenshot(self): self.xvfb_server.start_sync() self.assertTrue(self.xvfb_server.is_running(), 'xvfb server failed to start.') output_file = self.xvfb_server.get_screenshot() screenshot_img = Image.open(output_file) img_width, img_height = screenshot_img.size self.assertEqual(img_width, XVFBServer.WIDTH) self.assertEqual(img_height, XVFBServer.HEIGTH) self.assertTrue(is_black_image(screenshot_img)) os.remove(output_file)
def get_screenshot(self): self.assertTrue(self.gnome.is_running()) output_file = self.gnome.get_screenshot() screenshot_img = Image.open(output_file) img_width, img_height = screenshot_img.size self.assertEqual(img_width, Gnome.WIDTH) self.assertEqual(img_height, Gnome.HEIGTH) # It shouldn't be black since it should have the background set by the # user running the test in his Gnome desktop self.assertFalse(is_black_image(screenshot_img)) os.remove(output_file)