OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" | 13 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/test_launcher_utils.h" | 17 #include "chrome/test/base/test_launcher_utils.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
26 #include "third_party/skia/include/core/SkColor.h" | 26 #include "third_party/skia/include/core/SkColor.h" |
27 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
| 28 #include "ui/gfx/compositor/compositor_setup.h" |
28 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
29 #include "ui/gfx/test/gfx_test_utils.h" | |
30 | |
31 #if defined(USE_WEBKIT_COMPOSITOR) | |
32 #include "ui/gfx/compositor/compositor_setup.h" | |
33 #elif defined(VIEWS_COMPOSITOR) | |
34 #include "ui/gfx/compositor/compositor.h" | |
35 #endif | |
36 | 30 |
37 namespace { | 31 namespace { |
38 | 32 |
39 // Command line flag for overriding the default location for putting generated | 33 // Command line flag for overriding the default location for putting generated |
40 // test images that do not match references. | 34 // test images that do not match references. |
41 const char kGeneratedDir[] = "generated-dir"; | 35 const char kGeneratedDir[] = "generated-dir"; |
42 // Command line flag for overriding the default location for reference images. | 36 // Command line flag for overriding the default location for reference images. |
43 const char kReferenceDir[] = "reference-dir"; | 37 const char kReferenceDir[] = "reference-dir"; |
44 | 38 |
45 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG | 39 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 else | 92 else |
99 ref_img_dir_ = test_data_dir_.AppendASCII("gpu_reference"); | 93 ref_img_dir_ = test_data_dir_.AppendASCII("gpu_reference"); |
100 | 94 |
101 test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name(); | 95 test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name(); |
102 const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"}; | 96 const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"}; |
103 for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) { | 97 for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) { |
104 ReplaceFirstSubstringAfterOffset( | 98 ReplaceFirstSubstringAfterOffset( |
105 &test_name_, 0, test_status_prefixes[i], ""); | 99 &test_name_, 0, test_status_prefixes[i], ""); |
106 } | 100 } |
107 | 101 |
108 #if defined(USE_WEBKIT_COMPOSITOR) | |
109 ui::DisableTestCompositor(); | 102 ui::DisableTestCompositor(); |
110 #elif defined(VIEWS_COMPOSITOR) | |
111 ui::Compositor::set_compositor_factory_for_testing(NULL); | |
112 #endif | |
113 } | 103 } |
114 | 104 |
115 // If the existing ref image was saved from an revision older than the | 105 // If the existing ref image was saved from an revision older than the |
116 // ref_img_update_revision, refresh the ref image. | 106 // ref_img_update_revision, refresh the ref image. |
117 void RunPixelTest(const gfx::Size& tab_container_size, | 107 void RunPixelTest(const gfx::Size& tab_container_size, |
118 const FilePath& url, | 108 const FilePath& url, |
119 int64 ref_img_update_revision) { | 109 int64 ref_img_update_revision) { |
120 ref_img_revision_no_older_than_ = ref_img_update_revision; | 110 ref_img_revision_no_older_than_ = ref_img_update_revision; |
121 ObtainLocalRefImageFilePath(); | 111 ObtainLocalRefImageFilePath(); |
122 | 112 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // If test baseline needs to be updated after a given revision, update the | 404 // If test baseline needs to be updated after a given revision, update the |
415 // following number. If no revision requirement, then 0. | 405 // following number. If no revision requirement, then 0. |
416 const int64 ref_img_revision_update = 118461; | 406 const int64 ref_img_revision_update = 118461; |
417 | 407 |
418 gfx::Size container_size(250, 250); | 408 gfx::Size container_size(250, 250); |
419 FilePath url = | 409 FilePath url = |
420 test_data_dir().AppendASCII("pixel_canvas2d.html"); | 410 test_data_dir().AppendASCII("pixel_canvas2d.html"); |
421 RunPixelTest(container_size, url, ref_img_revision_update); | 411 RunPixelTest(container_size, url, ref_img_revision_update); |
422 } | 412 } |
423 | 413 |
OLD | NEW |