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

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

Issue 8510032: Add tests to make sure gpu blacklist actually block gpu features. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « chrome/test/data/gpu/feature_webgl.html ('k') | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/path_service.h"
8 #include "base/test/trace_event_analyzer.h"
9 #include "base/version.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/tracing.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/gpu/gpu_blacklist.h"
16 #include "content/browser/gpu/gpu_data_manager.h"
17 #include "net/base/net_util.h"
18
19 namespace {
20
21 class GpuFeatureTest : public InProcessBrowserTest {
22 public:
23 GpuFeatureTest() {}
24
25 virtual void SetUpCommandLine(CommandLine* command_line) {
26 // This enables DOM automation for tab contents.
27 EnableDOMAutomation();
28 }
29
30 void SetupBlacklist(const std::string& json_blacklist) {
31 scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0"));
32 GpuBlacklist* blacklist = new GpuBlacklist("1.0 unknown");
33
34 ASSERT_TRUE(blacklist->LoadGpuBlacklist(
35 json_blacklist, GpuBlacklist::kAllOs));
36 GpuDataManager::GetInstance()->SetBuiltInGpuBlacklist(blacklist);
37 }
38
39 void RunTest(const FilePath& url, bool expect_gpu_process) {
40 using namespace trace_analyzer;
41
42 FilePath test_path;
43 PathService::Get(chrome::DIR_TEST_DATA, &test_path);
44 test_path = test_path.Append(FILE_PATH_LITERAL("gpu"));
45 test_path = test_path.Append(url);
46
47 ASSERT_TRUE(file_util::PathExists(test_path))
48 << "Missing test file: " << test_path.value();
49
50 ASSERT_TRUE(tracing::BeginTracing("test_gpu"));
51
52 ui_test_utils::DOMMessageQueue message_queue;
53 // Have to use a new tab for the blacklist to work.
54 ui_test_utils::NavigateToURLWithDisposition(
55 browser(), net::FilePathToFileURL(test_path), NEW_FOREGROUND_TAB,
56 ui_test_utils::BROWSER_TEST_NONE);
57 // Wait for message indicating the test has finished running.
58 ASSERT_TRUE(message_queue.WaitForMessage(NULL));
59
60 std::string json_events;
61 ASSERT_TRUE(tracing::EndTracing(&json_events));
62
63 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events));
64 EXPECT_EQ(expect_gpu_process, analyzer->FindOneEvent(
65 Query(EVENT_NAME) == Query::String("GpuProcessLaunched")) != NULL);
66 }
67 };
68
69 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) {
70 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
71 EXPECT_EQ(flags.flags(), 0u);
72
73 const bool expect_gpu_process = true;
74 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
75 RunTest(url, expect_gpu_process);
76 }
77
78 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) {
79 const std::string json_blacklist =
80 "{\n"
81 " \"name\": \"gpu blacklist\",\n"
82 " \"version\": \"1.0\",\n"
83 " \"entries\": [\n"
84 " {\n"
85 " \"id\": 1,\n"
86 " \"blacklist\": [\n"
87 " \"accelerated_compositing\"\n"
88 " ]\n"
89 " }\n"
90 " ]\n"
91 "}";
92 SetupBlacklist(json_blacklist);
93 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
94 EXPECT_EQ(
95 flags.flags(),
96 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
97
98 const bool expect_gpu_process = false;
99 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
100 RunTest(url, expect_gpu_process);
101 }
102
103 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) {
104 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
105 EXPECT_EQ(flags.flags(), 0u);
106
107 const bool expect_gpu_process = true;
108 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
109 RunTest(url, expect_gpu_process);
110 }
111
112 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) {
113 const std::string json_blacklist =
114 "{\n"
115 " \"name\": \"gpu blacklist\",\n"
116 " \"version\": \"1.0\",\n"
117 " \"entries\": [\n"
118 " {\n"
119 " \"id\": 1,\n"
120 " \"blacklist\": [\n"
121 " \"webgl\"\n"
122 " ]\n"
123 " }\n"
124 " ]\n"
125 "}";
126 SetupBlacklist(json_blacklist);
127 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
128 EXPECT_EQ(
129 flags.flags(),
130 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
131
132 const bool expect_gpu_process = false;
133 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
134 RunTest(url, expect_gpu_process);
135 }
136
137 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) {
138 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
139 EXPECT_EQ(flags.flags(), 0u);
140
141 #if defined(OS_MACOSX)
142 // TODO(zmo): enabling Mac when skia backend is enabled.
143 const bool expect_gpu_process = false;
144 #else
145 const bool expect_gpu_process = true;
146 #endif
147 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
148 RunTest(url, expect_gpu_process);
149 }
150
151 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) {
152 const std::string json_blacklist =
153 "{\n"
154 " \"name\": \"gpu blacklist\",\n"
155 " \"version\": \"1.0\",\n"
156 " \"entries\": [\n"
157 " {\n"
158 " \"id\": 1,\n"
159 " \"blacklist\": [\n"
160 " \"accelerated_2d_canvas\"\n"
161 " ]\n"
162 " }\n"
163 " ]\n"
164 "}";
165 SetupBlacklist(json_blacklist);
166 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
167 EXPECT_EQ(
168 flags.flags(),
169 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas));
170
171 const bool expect_gpu_process = false;
172 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
173 RunTest(url, expect_gpu_process);
174 }
175
176 } // namespace anonymous
177
OLDNEW
« no previous file with comments | « chrome/test/data/gpu/feature_webgl.html ('k') | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698