Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: tools/telemetry/telemetry/core/platform_unittest.py

Issue 1415133005: [Telemetry] Enable screenshot taking on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use rgb(217, 115, 43) instead of green Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/internal/platform/mac_platform_backend.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform_unittest.py
diff --git a/tools/telemetry/telemetry/core/platform_unittest.py b/tools/telemetry/telemetry/core/platform_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..8a2983ed50684d9a745814b285750de9688f7aef
--- /dev/null
+++ b/tools/telemetry/telemetry/core/platform_unittest.py
@@ -0,0 +1,37 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import os
+import tempfile
+
+from telemetry import decorators
+from telemetry.util import image_util
+from telemetry.testing import tab_test_case
+
+
+class PlatformScreenshotTest(tab_test_case.TabTestCase):
+ def testScreenshotSupported(self):
+ if self._platform.GetOSName() in ('mac', 'android'):
+ self.assertTrue(self._platform.CanTakeScreenshot())
+
+ # Run this test in serial to avoid multiple browsers pop up on the screen.
+ @decorators.Isolated
+ def testScreenshot(self):
+ if not self._platform.CanTakeScreenshot():
+ logging.warning('Platform does not support screenshots, skipping test.')
+ return
+ tf = tempfile.NamedTemporaryFile(delete=False, suffix='.png')
+ tf.close()
+ try:
+ self.Navigate('screenshot_test.html')
+ self._platform.TakeScreenshot(tf.name)
+ # Assert that screenshot image contains the color of the triangle defined
+ # in screenshot_test.html.
+ img = image_util.FromPngFile(tf.name)
+ screenshot_pixels = image_util.Pixels(img)
+ special_colored_pixel = bytearray([217, 115, 43])
+ self.assertTrue(special_colored_pixel in screenshot_pixels)
+ finally:
+ os.remove(tf.name)
« no previous file with comments | « no previous file | tools/telemetry/telemetry/internal/platform/mac_platform_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698