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

Side by Side Diff: compute_engine_scripts/telemetry/telemetry_slave_scripts/write_json_summary_test.py

Issue 148093012: Add magnifying ability, perceptual diff and improve layout of Skia Tryserver HTML output (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Rebase Created 6 years, 10 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Tests for module write_json_summary.py""" 6 """Tests for module write_json_summary.py"""
7 7
8 import filecmp 8 import filecmp
9 import os 9 import os
10 import shutil 10 import shutil
11 import tempfile 11 import tempfile
12 import unittest 12 import unittest
13 13
14 import write_json_summary 14 import write_json_summary
15 15
16 16
17 class TestWriteJsonSummary(unittest.TestCase): 17 class TestWriteJsonSummary(unittest.TestCase):
18 18
19 def setUp(self): 19 def setUp(self):
20 self._test_json_dir = os.path.join( 20 self._test_json_dir = os.path.join(
21 os.path.dirname(os.path.realpath(__file__)), 'test_data') 21 os.path.dirname(os.path.realpath(__file__)), 'test_data')
22 self._output_file_name = 'summary.json' 22 self._output_file_name = 'summary.json'
23 self._gm_json_path = os.path.join(self._test_json_dir, 'gm_json_mock.py') 23 self._gm_json_path = os.path.join(self._test_json_dir, 'gm_json_mock.py')
24 self._imagediffdb_path = os.path.join(self._test_json_dir, 24 self._imagediffdb_path = os.path.join(self._test_json_dir,
25 'imagediffdb_mock.py') 25 'imagediffdb_mock.py')
26 self._skpdiff_output_csv = os.path.join(self._test_json_dir, 'output.csv')
26 self._actual_output_dir = tempfile.mkdtemp() 27 self._actual_output_dir = tempfile.mkdtemp()
27 self._actual_output_file_path = os.path.join(self._actual_output_dir, 28 self._actual_output_file_path = os.path.join(self._actual_output_dir,
28 self._output_file_name) 29 self._output_file_name)
29 self._gs_output_dir = 'gs://dummy-bucket/output-dir' 30 self._gs_output_dir = 'gs://dummy-bucket/output-dir'
30 self._gs_skp_dir = 'gs://dummy-bucket/skps' 31 self._gs_skp_dir = 'gs://dummy-bucket/skps'
31 self._img_root = '/tmp/' 32 self._img_root = '/tmp/'
32 self._nopatch_img_dir_name = 'nopatch' 33 self._nopatch_img_dir_name = 'nopatch'
33 self._withpatch_img_dir_name = 'withpatch' 34 self._withpatch_img_dir_name = 'withpatch'
34 self._slave_num = 1 35 self._slave_num = 1
35 36
36 def tearDown(self): 37 def tearDown(self):
37 shutil.rmtree(self._actual_output_dir) 38 shutil.rmtree(self._actual_output_dir)
38 39
39 def test_DifferentFiles(self): 40 def test_DifferentFiles(self):
40 write_json_summary.WriteJsonSummary( 41 write_json_summary.WriteJsonSummary(
41 img_root=self._img_root, 42 img_root=self._img_root,
42 nopatch_json=os.path.join(self._test_json_dir, 'output1.json'), 43 nopatch_json=os.path.join(self._test_json_dir, 'output1.json'),
43 nopatch_img_dir_name=self._nopatch_img_dir_name, 44 nopatch_img_dir_name=self._nopatch_img_dir_name,
44 withpatch_json=os.path.join(self._test_json_dir, 'output2.json'), 45 withpatch_json=os.path.join(self._test_json_dir, 'output2.json'),
45 withpatch_img_dir_name=self._withpatch_img_dir_name, 46 withpatch_img_dir_name=self._withpatch_img_dir_name,
46 output_file_path=self._actual_output_file_path, 47 output_file_path=self._actual_output_file_path,
47 gs_output_dir=self._gs_output_dir, 48 gs_output_dir=self._gs_output_dir,
48 gs_skp_dir=self._gs_skp_dir, 49 gs_skp_dir=self._gs_skp_dir,
49 slave_num=self._slave_num, 50 slave_num=self._slave_num,
50 gm_json_path=self._gm_json_path, 51 gm_json_path=self._gm_json_path,
51 imagediffdb_path=self._imagediffdb_path) 52 imagediffdb_path=self._imagediffdb_path,
53 skpdiff_output_csv=self._skpdiff_output_csv)
52 54
53 self.assertTrue( 55 self.assertTrue(
54 filecmp.cmp(os.path.join(self._test_json_dir, self._output_file_name), 56 filecmp.cmp(os.path.join(self._test_json_dir, self._output_file_name),
55 self._actual_output_file_path)) 57 self._actual_output_file_path))
56 58
57 def test_NoDifferentFiles(self): 59 def test_NoDifferentFiles(self):
58 write_json_summary.WriteJsonSummary( 60 write_json_summary.WriteJsonSummary(
59 img_root=self._img_root, 61 img_root=self._img_root,
60 nopatch_json=os.path.join(self._test_json_dir, 'output1.json'), 62 nopatch_json=os.path.join(self._test_json_dir, 'output1.json'),
61 nopatch_img_dir_name=self._nopatch_img_dir_name, 63 nopatch_img_dir_name=self._nopatch_img_dir_name,
62 withpatch_json=os.path.join(self._test_json_dir, 'output1.json'), 64 withpatch_json=os.path.join(self._test_json_dir, 'output1.json'),
63 withpatch_img_dir_name=self._withpatch_img_dir_name, 65 withpatch_img_dir_name=self._withpatch_img_dir_name,
64 output_file_path=self._actual_output_file_path, 66 output_file_path=self._actual_output_file_path,
65 gs_output_dir=self._gs_output_dir, 67 gs_output_dir=self._gs_output_dir,
66 gs_skp_dir=self._gs_skp_dir, 68 gs_skp_dir=self._gs_skp_dir,
67 slave_num=self._slave_num, 69 slave_num=self._slave_num,
68 gm_json_path=self._gm_json_path, 70 gm_json_path=self._gm_json_path,
69 imagediffdb_path=self._imagediffdb_path) 71 imagediffdb_path=self._imagediffdb_path,
72 skpdiff_output_csv=self._skpdiff_output_csv)
70 73
71 self.assertFalse(os.path.isfile(self._actual_output_file_path)) 74 self.assertFalse(os.path.isfile(self._actual_output_file_path))
72 75
73 76
74 if __name__ == '__main__': 77 if __name__ == '__main__':
75 unittest.main() 78 unittest.main()
76 79
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698