| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 import json | |
| 8 import unittest | |
| 9 from PIL import Image | |
| 10 | |
| 11 import chrome_utils | |
| 12 from ..common import mock_cloud_bucket | |
| 13 | |
| 14 | |
| 15 class ChromeUtilsTest(unittest.TestCase): | |
| 16 """Unittest for ChromeUtils.""" | |
| 17 | |
| 18 def setUp(self): | |
| 19 self.cloud_bucket = mock_cloud_bucket.MockCloudBucket() | |
| 20 self.white_utils = chrome_utils.ChromeUtils( | |
| 21 self.cloud_bucket, 'versions.json', | |
| 22 lambda: Image.new('RGBA', (10, 10), (255, 255, 255, 255))) | |
| 23 self.black_utils = chrome_utils.ChromeUtils( | |
| 24 self.cloud_bucket, 'versions.json', | |
| 25 lambda: Image.new('RGBA', (10, 10), (0, 0, 0, 255))) | |
| 26 | |
| 27 def testGenerateExpectationsRunComparison(self): | |
| 28 self.white_utils.GenerateExpectation('device', 'test', '1.1.1.1') | |
| 29 self.white_utils.UpdateExpectationVersion('1.1.1.1') | |
| 30 self.white_utils.PerformComparison('test1', 'device', 'test', '1.1.1.1') | |
| 31 expect_name = self.white_utils._CreateExpectationName( | |
| 32 'device', 'test', '1.1.1.1') | |
| 33 self.assertFalse(self.white_utils._ispy.FailureExists('test1', expect_name)) | |
| 34 self.black_utils.PerformComparison('test2', 'device', 'test', '1.1.1.1') | |
| 35 self.assertTrue(self.white_utils._ispy.FailureExists('test2', expect_name)) | |
| 36 | |
| 37 def testUpdateExpectationVersion(self): | |
| 38 self.white_utils.UpdateExpectationVersion('1.0.0.0') | |
| 39 self.white_utils.UpdateExpectationVersion('1.0.4.0') | |
| 40 self.white_utils.UpdateExpectationVersion('2.1.5.0') | |
| 41 self.white_utils.UpdateExpectationVersion('1.1.5.0') | |
| 42 self.white_utils.UpdateExpectationVersion('0.0.0.0') | |
| 43 self.white_utils.UpdateExpectationVersion('1.1.5.0') | |
| 44 self.white_utils.UpdateExpectationVersion('0.0.0.1') | |
| 45 versions = json.loads(self.cloud_bucket.DownloadFile('versions.json')) | |
| 46 self.assertEqual(versions, | |
| 47 ['2.1.5.0', '1.1.5.0', '1.0.4.0', '1.0.0.0', '0.0.0.1', '0.0.0.0']) | |
| 48 | |
| 49 | |
| 50 if __name__ == '__main__': | |
| 51 unittest.main() | |
| OLD | NEW |