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

Side by Side Diff: chrome/test/gpu/gpu_feature_browsertest.cc

Issue 8692013: Improve GPU tests to fail when GPU drawing fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests seem to be fixed Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/test/trace_event_analyzer.h" 8 #include "base/test/trace_event_analyzer.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/tracing.h" 13 #include "chrome/test/base/tracing.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/gpu/gpu_blacklist.h" 15 #include "content/browser/gpu/gpu_blacklist.h"
16 #include "content/browser/gpu/gpu_data_manager.h" 16 #include "content/browser/gpu/gpu_data_manager.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 18
19 namespace { 19 namespace {
20 20
21 typedef uint32 GpuResultFlags;
22 #define EXPECT_NO_GPU_PROCESS GpuResultFlags(0)
23 #define EXPECT_GPU_PROCESS GpuResultFlags(1<<0)
24 #define EXPECT_GPU_SWAP_BUFFERS GpuResultFlags(1<<1)
25
21 class GpuFeatureTest : public InProcessBrowserTest { 26 class GpuFeatureTest : public InProcessBrowserTest {
22 public: 27 public:
23 GpuFeatureTest() {} 28 GpuFeatureTest() {}
24 29
25 virtual void SetUpCommandLine(CommandLine* command_line) { 30 virtual void SetUpCommandLine(CommandLine* command_line) {
26 // This enables DOM automation for tab contents. 31 // This enables DOM automation for tab contents.
27 EnableDOMAutomation(); 32 EnableDOMAutomation();
28 } 33 }
29 34
30 void SetupBlacklist(const std::string& json_blacklist) { 35 void SetupBlacklist(const std::string& json_blacklist) {
31 scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0")); 36 scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0"));
32 GpuBlacklist* blacklist = new GpuBlacklist("1.0"); 37 GpuBlacklist* blacklist = new GpuBlacklist("1.0");
33 38
34 ASSERT_TRUE(blacklist->LoadGpuBlacklist( 39 ASSERT_TRUE(blacklist->LoadGpuBlacklist(
35 json_blacklist, GpuBlacklist::kAllOs)); 40 json_blacklist, GpuBlacklist::kAllOs));
36 GpuDataManager::GetInstance()->SetBuiltInGpuBlacklist(blacklist); 41 GpuDataManager::GetInstance()->SetBuiltInGpuBlacklist(blacklist);
37 } 42 }
38 43
39 void RunTest(const FilePath& url, bool expect_gpu_process) { 44 void RunTest(const FilePath& url, GpuResultFlags expectations) {
40 using namespace trace_analyzer; 45 using namespace trace_analyzer;
41 46
47 bool expect_gpu_process = (expectations & EXPECT_GPU_PROCESS);
48 bool expect_gpu_swap = (expectations & EXPECT_GPU_SWAP_BUFFERS);
49
42 FilePath test_path; 50 FilePath test_path;
43 PathService::Get(chrome::DIR_TEST_DATA, &test_path); 51 PathService::Get(chrome::DIR_TEST_DATA, &test_path);
44 test_path = test_path.Append(FILE_PATH_LITERAL("gpu")); 52 test_path = test_path.Append(FILE_PATH_LITERAL("gpu"));
45 test_path = test_path.Append(url); 53 test_path = test_path.Append(url);
46 54
47 ASSERT_TRUE(file_util::PathExists(test_path)) 55 ASSERT_TRUE(file_util::PathExists(test_path))
48 << "Missing test file: " << test_path.value(); 56 << "Missing test file: " << test_path.value();
49 57
50 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); 58 ASSERT_TRUE(tracing::BeginTracing("test_gpu"));
51 59
52 ui_test_utils::DOMMessageQueue message_queue; 60 ui_test_utils::DOMMessageQueue message_queue;
53 // Have to use a new tab for the blacklist to work. 61 // Have to use a new tab for the blacklist to work.
54 ui_test_utils::NavigateToURLWithDisposition( 62 ui_test_utils::NavigateToURLWithDisposition(
55 browser(), net::FilePathToFileURL(test_path), NEW_FOREGROUND_TAB, 63 browser(), net::FilePathToFileURL(test_path), NEW_FOREGROUND_TAB,
56 ui_test_utils::BROWSER_TEST_NONE); 64 ui_test_utils::BROWSER_TEST_NONE);
57 // Wait for message indicating the test has finished running. 65 // Wait for message indicating the test has finished running.
58 ASSERT_TRUE(message_queue.WaitForMessage(NULL)); 66 ASSERT_TRUE(message_queue.WaitForMessage(NULL));
59 67
60 std::string json_events; 68 std::string json_events;
61 ASSERT_TRUE(tracing::EndTracing(&json_events)); 69 ASSERT_TRUE(tracing::EndTracing(&json_events));
62 70
63 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events)); 71 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events));
64 EXPECT_EQ(expect_gpu_process, analyzer->FindOneEvent( 72 EXPECT_EQ(expect_gpu_process, analyzer->FindOneEvent(
65 Query(EVENT_NAME) == Query::String("GpuProcessLaunched")) != NULL); 73 Query(EVENT_NAME) == Query::String("GpuProcessLaunched")) != NULL);
74 if (expect_gpu_swap) {
75 EXPECT_TRUE(analyzer->FindOneEvent(
76 Query(EVENT_NAME) == Query::String("SwapBuffers")) != NULL);
77 }
Zhenyao Mo 2011/11/30 18:58:47 This should match the previous line EXPECT_EQ styl
jbates 2011/11/30 20:21:52 Done.
66 } 78 }
67 }; 79 };
68 80
69 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { 81 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) {
70 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); 82 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
71 EXPECT_EQ(flags.flags(), 0u); 83 EXPECT_EQ(flags.flags(), 0u);
72 84
73 const bool expect_gpu_process = true;
74 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); 85 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
75 RunTest(url, expect_gpu_process); 86 RunTest(url, EXPECT_GPU_PROCESS | EXPECT_GPU_SWAP_BUFFERS);
76 } 87 }
77 88
78 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) { 89 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) {
79 const std::string json_blacklist = 90 const std::string json_blacklist =
80 "{\n" 91 "{\n"
81 " \"name\": \"gpu blacklist\",\n" 92 " \"name\": \"gpu blacklist\",\n"
82 " \"version\": \"1.0\",\n" 93 " \"version\": \"1.0\",\n"
83 " \"entries\": [\n" 94 " \"entries\": [\n"
84 " {\n" 95 " {\n"
85 " \"id\": 1,\n" 96 " \"id\": 1,\n"
86 " \"blacklist\": [\n" 97 " \"blacklist\": [\n"
87 " \"accelerated_compositing\"\n" 98 " \"accelerated_compositing\"\n"
88 " ]\n" 99 " ]\n"
89 " }\n" 100 " }\n"
90 " ]\n" 101 " ]\n"
91 "}"; 102 "}";
92 SetupBlacklist(json_blacklist); 103 SetupBlacklist(json_blacklist);
93 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); 104 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
94 EXPECT_EQ( 105 EXPECT_EQ(
95 flags.flags(), 106 flags.flags(),
96 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)); 107 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
97 108
98 const bool expect_gpu_process = false;
99 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); 109 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
100 RunTest(url, expect_gpu_process); 110 RunTest(url, EXPECT_NO_GPU_PROCESS);
101 } 111 }
102 112
103 #if defined(OS_LINUX) 113 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, FLAKY_WebGLAllowed) {
104 // http://crbug.com/104142
105 #define MAYBE_WebGLAllowed DISABLED_WebGLAllowed
106 #else
107 #define MAYBE_WebGLAllowed WebGLAllowed
108 #endif
jbates 2011/11/30 02:24:35 Let's see if this works now...
109 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_WebGLAllowed) {
110 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); 114 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
111 EXPECT_EQ(flags.flags(), 0u); 115 EXPECT_EQ(flags.flags(), 0u);
112 116
113 const bool expect_gpu_process = true;
114 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); 117 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
115 RunTest(url, expect_gpu_process); 118 RunTest(url, EXPECT_GPU_PROCESS | EXPECT_GPU_SWAP_BUFFERS);
116 } 119 }
117 120
118 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { 121 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) {
119 const std::string json_blacklist = 122 const std::string json_blacklist =
120 "{\n" 123 "{\n"
121 " \"name\": \"gpu blacklist\",\n" 124 " \"name\": \"gpu blacklist\",\n"
122 " \"version\": \"1.0\",\n" 125 " \"version\": \"1.0\",\n"
123 " \"entries\": [\n" 126 " \"entries\": [\n"
124 " {\n" 127 " {\n"
125 " \"id\": 1,\n" 128 " \"id\": 1,\n"
126 " \"blacklist\": [\n" 129 " \"blacklist\": [\n"
127 " \"webgl\"\n" 130 " \"webgl\"\n"
128 " ]\n" 131 " ]\n"
129 " }\n" 132 " }\n"
130 " ]\n" 133 " ]\n"
131 "}"; 134 "}";
132 SetupBlacklist(json_blacklist); 135 SetupBlacklist(json_blacklist);
133 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); 136 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
134 EXPECT_EQ( 137 EXPECT_EQ(
135 flags.flags(), 138 flags.flags(),
136 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); 139 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
137 140
138 const bool expect_gpu_process = false;
139 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); 141 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
140 RunTest(url, expect_gpu_process); 142 RunTest(url, EXPECT_NO_GPU_PROCESS);
141 } 143 }
142 144
143 #if defined(OS_LINUX) 145 #if defined(OS_LINUX)
144 // http://crbug.com/104142 146 // http://crbug.com/104142
145 #define Canvas2DAllowed FLAKY_Canvas2DAllowed 147 #define Canvas2DAllowed FLAKY_Canvas2DAllowed
146 #endif 148 #endif
147 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) { 149 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) {
148 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); 150 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
149 EXPECT_EQ(flags.flags(), 0u); 151 EXPECT_EQ(flags.flags(), 0u);
150 152
151 #if defined(OS_MACOSX) 153 #if defined(OS_MACOSX)
152 // TODO(zmo): enabling Mac when skia backend is enabled. 154 // TODO(zmo): enabling Mac when skia backend is enabled.
153 const bool expect_gpu_process = false; 155 const GpuResultFlags expectations = EXPECT_NO_GPU_PROCESS;
154 #else 156 #else
155 const bool expect_gpu_process = true; 157 const GpuResultFlags expectations = EXPECT_GPU_PROCESS |
158 EXPECT_GPU_SWAP_BUFFERS;
156 #endif 159 #endif
157 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); 160 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
158 RunTest(url, expect_gpu_process); 161 RunTest(url, expectations);
159 } 162 }
160 163
161 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) { 164 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) {
162 const std::string json_blacklist = 165 const std::string json_blacklist =
163 "{\n" 166 "{\n"
164 " \"name\": \"gpu blacklist\",\n" 167 " \"name\": \"gpu blacklist\",\n"
165 " \"version\": \"1.0\",\n" 168 " \"version\": \"1.0\",\n"
166 " \"entries\": [\n" 169 " \"entries\": [\n"
167 " {\n" 170 " {\n"
168 " \"id\": 1,\n" 171 " \"id\": 1,\n"
169 " \"blacklist\": [\n" 172 " \"blacklist\": [\n"
170 " \"accelerated_2d_canvas\"\n" 173 " \"accelerated_2d_canvas\"\n"
171 " ]\n" 174 " ]\n"
172 " }\n" 175 " }\n"
173 " ]\n" 176 " ]\n"
174 "}"; 177 "}";
175 SetupBlacklist(json_blacklist); 178 SetupBlacklist(json_blacklist);
176 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); 179 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
177 EXPECT_EQ( 180 EXPECT_EQ(
178 flags.flags(), 181 flags.flags(),
179 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)); 182 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas));
180 183
181 const bool expect_gpu_process = false;
182 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); 184 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
183 RunTest(url, expect_gpu_process); 185 RunTest(url, EXPECT_NO_GPU_PROCESS);
184 } 186 }
185 187
186 } // namespace anonymous 188 } // namespace anonymous
187 189
OLDNEW
« chrome/test/data/gpu/feature_webgl.html ('K') | « chrome/test/data/gpu/feature_webgl.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698