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

Side by Side Diff: content/test/gpu/gpu_tests/maps.py

Issue 99253005: [Telemetry] Rename PngBitmap->Bitmap and move it to core. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/pixel.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Runs a Google Maps pixel test. 5 """Runs a Google Maps pixel test.
6 Performs several common navigation actions on the map (pan, zoom, rotate) then 6 Performs several common navigation actions on the map (pan, zoom, rotate) then
7 captures a screenshot and compares selected pixels against expected values""" 7 captures a screenshot and compares selected pixels against expected values"""
8 8
9 import json 9 import json
10 import optparse 10 import optparse
11 import os 11 import os
12 import re 12 import re
13 13
14 import maps_expectations 14 import maps_expectations
15 15
16 from telemetry import test 16 from telemetry import test
17 from telemetry.core.backends import png_bitmap 17 from telemetry.core.backends import bitmap
18 from telemetry.core import util 18 from telemetry.core import util
19 from telemetry.page import page_test 19 from telemetry.page import page_test
20 from telemetry.page import page_set 20 from telemetry.page import page_set
21 21
22 test_data_dir = os.path.abspath(os.path.join( 22 test_data_dir = os.path.abspath(os.path.join(
23 os.path.dirname(__file__), '..', '..', 'data', 'gpu')) 23 os.path.dirname(__file__), '..', '..', 'data', 'gpu'))
24 24
25 default_generated_data_dir = os.path.join(test_data_dir, 'generated') 25 default_generated_data_dir = os.path.join(test_data_dir, 'generated')
26 26
27 class MapsValidator(page_test.PageTest): 27 class MapsValidator(page_test.PageTest):
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 location = expectation["location"] 90 location = expectation["location"]
91 x = location[0] * devicePixelRatio 91 x = location[0] * devicePixelRatio
92 y = location[1] * devicePixelRatio 92 y = location[1] * devicePixelRatio
93 93
94 if x < 0 or y < 0 or x > screenshot.width or y > screenshot.height: 94 if x < 0 or y < 0 or x > screenshot.width or y > screenshot.height:
95 raise page_test.Failure( 95 raise page_test.Failure(
96 'Expected pixel location [%d, %d] is out of range on [%d, %d] image' % 96 'Expected pixel location [%d, %d] is out of range on [%d, %d] image' %
97 (x, y, screenshot.width, screenshot.height)) 97 (x, y, screenshot.width, screenshot.height))
98 98
99 pixel_color = screenshot.GetPixelColor(x, y) 99 pixel_color = screenshot.GetPixelColor(x, y)
100 expect_color = png_bitmap.PngColor( 100 expect_color = bitmap.RgbaColor(
101 expectation["color"][0], 101 expectation["color"][0],
102 expectation["color"][1], 102 expectation["color"][1],
103 expectation["color"][2]) 103 expectation["color"][2])
104 iter_result = pixel_color.IsEqual(expect_color, expectation["tolerance"]) 104 iter_result = pixel_color.IsEqual(expect_color, expectation["tolerance"])
105 if not iter_result: 105 if not iter_result:
106 raise page_test.Failure('Expected pixel at ' + str(location) + 106 raise page_test.Failure('Expected pixel at ' + str(location) +
107 ' to be ' + 107 ' to be ' +
108 str(expectation["color"]) + " but got [" + 108 str(expectation["color"]) + " but got [" +
109 str(pixel_color.r) + ", " + 109 str(pixel_color.r) + ", " +
110 str(pixel_color.g) + ", " + 110 str(pixel_color.g) + ", " +
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 'navigate_steps': [ 170 'navigate_steps': [
171 { 'action': 'navigate' }, 171 { 'action': 'navigate' },
172 { 'action': 'wait', 'javascript': 'window.testDone' } 172 { 'action': 'wait', 'javascript': 'window.testDone' }
173 ], 173 ],
174 'pixel_expectations': 'data/maps_001_expectations.json' 174 'pixel_expectations': 'data/maps_001_expectations.json'
175 } 175 }
176 ] 176 ]
177 } 177 }
178 178
179 return page_set.PageSet.FromDict(page_set_dict, page_set_path) 179 return page_set.PageSet.FromDict(page_set_dict, page_set_path)
OLDNEW
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/pixel.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698