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

Unified Diff: chrome/test/functional/ispy/common/chrome_utils_unittest.py

Issue 106523003: [I-Spy] Add support for rebaselining expectations from the web UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing dom.py Created 6 years, 12 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: chrome/test/functional/ispy/common/chrome_utils_unittest.py
diff --git a/chrome/test/functional/ispy/common/chrome_utils_unittest.py b/chrome/test/functional/ispy/common/chrome_utils_unittest.py
new file mode 100755
index 0000000000000000000000000000000000000000..0bf90a53dded98980e620262b32679ec33b47e91
--- /dev/null
+++ b/chrome/test/functional/ispy/common/chrome_utils_unittest.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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 json
+import unittest
+from PIL import Image
+
+import chrome_utils
+from ..common import cloud_bucket
+from ..common import mock_cloud_bucket
+
+
+class ChromeUtilsTest(unittest.TestCase):
+ """Unittest for ChromeUtils."""
+
+ def setUp(self):
+ self.cloud_bucket = mock_cloud_bucket.MockCloudBucket()
+ self.chrome_util = chrome_utils.ChromeUtils(self.cloud_bucket)
+ self.white_img = Image.new('RGBA', (10, 10), (255, 255, 255, 255))
+ self.black_img = Image.new('RGBA', (10, 10), (0, 0, 0, 255))
+
+ def testGenerateExpectationsRunComparison(self):
+ self.chrome_util.GenerateExpectation(
+ 'device', 'test', '1.1.1.1', 'versions.json',
+ [self.white_img, self.white_img])
+ self.chrome_util.UpdateExpectationVersion('1.1.1.1', 'versions.json')
+ self.chrome_util.PerformComparison(
+ 'test1', 'device', 'test', '1.1.1.1', 'versions.json', self.white_img)
+ expect_name = self.chrome_util._CreateExpectationName(
+ 'device', 'test', '1.1.1.1')
+ self.assertFalse(self.chrome_util._ispy.FailureExists('test1', expect_name))
+ self.chrome_util.PerformComparison(
+ 'test2', 'device', 'test', '1.1.1.1','versions.json', self.black_img)
+ self.assertTrue(self.chrome_util._ispy.FailureExists('test2', expect_name))
+
+ def testUpdateExpectationVersion(self):
+ self.chrome_util.UpdateExpectationVersion('1.0.0.0', 'versions.json')
+ self.chrome_util.UpdateExpectationVersion('1.0.4.0', 'versions.json')
+ self.chrome_util.UpdateExpectationVersion('2.1.5.0', 'versions.json')
+ self.chrome_util.UpdateExpectationVersion('1.1.5.0', 'versions.json')
+ self.chrome_util.UpdateExpectationVersion('0.0.0.0', 'versions.json')
+ self.chrome_util.UpdateExpectationVersion('1.1.5.0', 'versions.json')
+ self.chrome_util.UpdateExpectationVersion('0.0.0.1', 'versions.json')
+ versions = json.loads(self.cloud_bucket.DownloadFile('versions.json'))
+ self.assertEqual(versions,
+ ['2.1.5.0', '1.1.5.0', '1.0.4.0', '1.0.0.0', '0.0.0.1', '0.0.0.0'])
+
+ def testPerformComparisonAndPrepareExpectation(self):
+ self.assertFalse(self.chrome_util.CanRebaselineToTestRun('test'))
+ self.assertRaises(
+ cloud_bucket.FileNotFoundError,
+ self.chrome_util.PerformComparisonAndPrepareExpectation,
+ 'test', 'device', 'expect', '1.0', 'versions.json',
+ [self.white_img, self.white_img])
+ self.assertTrue(self.chrome_util.CanRebaselineToTestRun('test'))
+ self.chrome_util.RebaselineToTestRun('test')
+ versions = json.loads(self.cloud_bucket.DownloadFile('versions.json'))
+ self.assertEqual(versions, ['1.0'])
+ self.chrome_util.PerformComparisonAndPrepareExpectation(
+ 'test1', 'device', 'expect', '1.1', 'versions.json',
+ [self.white_img, self.white_img])
+
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « chrome/test/functional/ispy/common/chrome_utils.py ('k') | chrome/test/functional/ispy/common/ispy_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698