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

Unified Diff: tools/perf/contrib/cluster_telemetry/screenshot_unittest.py

Issue 2923163007: Implemented telemetry benchmark that loads page and outputs screenshot. (Closed)
Patch Set: More detailed logging, unit test now returns if not Linux Created 3 years, 6 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
Index: tools/perf/contrib/cluster_telemetry/screenshot_unittest.py
diff --git a/tools/perf/contrib/cluster_telemetry/screenshot_unittest.py b/tools/perf/contrib/cluster_telemetry/screenshot_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..4127343ab8be64f72a85be55f0db64515b53e8fe
--- /dev/null
+++ b/tools/perf/contrib/cluster_telemetry/screenshot_unittest.py
@@ -0,0 +1,36 @@
+# Copyright 2017 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 os
+import platform
+import shutil
+import tempfile
+
+from telemetry.testing import options_for_unittests
+from telemetry.testing import page_test_test_case
+from contrib.cluster_telemetry import screenshot
+
+class ScreenshotUnitTest(page_test_test_case.PageTestTestCase):
+
+ def setUp(self):
+ self._options = options_for_unittests.GetCopy()
+ self._png_outdir = tempfile.mkdtemp('_png_test')
+
+ def tearDown(self):
+ shutil.rmtree(self._png_outdir)
+
+ def testScreenshot(self):
+ # Screenshots for Cluster Telemetry purposes currently only supported on
+ # Linux platform.
+ if platform.system() != 'Linux':
nednguyen 2017/06/09 18:11:09 You would want to do @decorators.Enabled('linux')
+ return
+
+ page_set = self.CreateStorySetFromFileInUnittestDataDir('blank.html')
+ measurement = screenshot.Screenshot(self._png_outdir)
+ self.RunMeasurement(measurement, page_set, options=self._options)
+
+ path = self._png_outdir + '/' + page_set.stories[0].file_safe_name + '.png'
+ self.assertTrue(os.path.exists(path))
+ self.assertTrue(os.path.isfile(path))
+ self.assertTrue(os.access(path, os.R_OK))
nednguyen 2017/06/09 18:11:09 In general, test should not leave files around aft
lchoi 2017/06/09 18:16:51 I'm pretty sure the tearDown() fn above takes care
nednguyen 2017/06/09 18:22:59 Ah right. Sorry that i missed the tearDown

Powered by Google App Engine
This is Rietveld 408576698