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

Side by Side Diff: content/browser/gpu/gpu_memory_test.cc

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
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/callback.h" 5 #include "base/callback.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "content/public/browser/gpu_data_manager.h" 8 #include "content/public/browser/gpu_data_manager.h"
9 #include "content/public/browser/gpu_data_manager_observer.h" 9 #include "content/public/browser/gpu_data_manager_observer.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 class GpuMemoryTest : public content::ContentBrowserTest { 67 class GpuMemoryTest : public content::ContentBrowserTest {
68 public: 68 public:
69 GpuMemoryTest() 69 GpuMemoryTest()
70 : allow_tests_to_run_(false), 70 : allow_tests_to_run_(false),
71 has_used_first_shell_(false) { 71 has_used_first_shell_(false) {
72 } 72 }
73 virtual ~GpuMemoryTest() { 73 virtual ~GpuMemoryTest() {
74 } 74 }
75 75
76 virtual void SetUpInProcessBrowserTestFixture() { 76 virtual void SetUpInProcessBrowserTestFixture() {
77 FilePath test_dir; 77 base::FilePath test_dir;
78 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); 78 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir));
79 gpu_test_dir_ = test_dir.AppendASCII("gpu"); 79 gpu_test_dir_ = test_dir.AppendASCII("gpu");
80 } 80 }
81 81
82 virtual void SetUpCommandLine(CommandLine* command_line) { 82 virtual void SetUpCommandLine(CommandLine* command_line) {
83 command_line->AppendSwitch(switches::kEnableLogging); 83 command_line->AppendSwitch(switches::kEnableLogging);
84 command_line->AppendSwitch(switches::kForceCompositingMode); 84 command_line->AppendSwitch(switches::kForceCompositingMode);
85 command_line->AppendSwitchASCII(switches::kForceGpuMemAvailableMb, 85 command_line->AppendSwitchASCII(switches::kForceGpuMemAvailableMb,
86 kMemoryLimitMBSwitch); 86 kMemoryLimitMBSwitch);
87 // Only run this on GPU bots for now. These tests should work with 87 // Only run this on GPU bots for now. These tests should work with
(...skipping 10 matching lines...) Expand all
98 98
99 enum PageType { 99 enum PageType {
100 PAGE_CSS3D, 100 PAGE_CSS3D,
101 PAGE_WEBGL, 101 PAGE_WEBGL,
102 }; 102 };
103 103
104 // Load a page and consume a specified amount of GPU memory. 104 // Load a page and consume a specified amount of GPU memory.
105 void LoadPage(content::Shell* tab_to_load, 105 void LoadPage(content::Shell* tab_to_load,
106 PageType page_type, 106 PageType page_type,
107 size_t mb_to_use) { 107 size_t mb_to_use) {
108 FilePath url; 108 base::FilePath url;
109 switch (page_type) { 109 switch (page_type) {
110 case PAGE_CSS3D: 110 case PAGE_CSS3D:
111 url = gpu_test_dir_.AppendASCII("mem_css3d.html"); 111 url = gpu_test_dir_.AppendASCII("mem_css3d.html");
112 break; 112 break;
113 case PAGE_WEBGL: 113 case PAGE_WEBGL:
114 url = gpu_test_dir_.AppendASCII("mem_webgl.html"); 114 url = gpu_test_dir_.AppendASCII("mem_webgl.html");
115 break; 115 break;
116 } 116 }
117 117
118 content::NavigateToURL(tab_to_load, net::FilePathToFileURL(url)); 118 content::NavigateToURL(tab_to_load, net::FilePathToFileURL(url));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 size_t GetMemoryUsageMbytes() { 219 size_t GetMemoryUsageMbytes() {
220 GpuMemoryBytesAllocatedObserver observer; 220 GpuMemoryBytesAllocatedObserver observer;
221 observer.GetBytesAllocated(); 221 observer.GetBytesAllocated();
222 return observer.GetBytesAllocated() / 1048576; 222 return observer.GetBytesAllocated() / 1048576;
223 } 223 }
224 224
225 bool allow_tests_to_run_; 225 bool allow_tests_to_run_;
226 std::set<content::Shell*> tabs_; 226 std::set<content::Shell*> tabs_;
227 std::set<content::Shell*> visible_tabs_; 227 std::set<content::Shell*> visible_tabs_;
228 bool has_used_first_shell_; 228 bool has_used_first_shell_;
229 FilePath gpu_test_dir_; 229 base::FilePath gpu_test_dir_;
230 }; 230 };
231 231
232 // When trying to load something that doesn't fit into our total GPU memory 232 // When trying to load something that doesn't fit into our total GPU memory
233 // limit, we shouldn't exceed that limit. 233 // limit, we shouldn't exceed that limit.
234 IN_PROC_BROWSER_TEST_F(GpuMemoryTest, SingleWindowDoesNotExceedLimit) { 234 IN_PROC_BROWSER_TEST_F(GpuMemoryTest, SingleWindowDoesNotExceedLimit) {
235 if (!AllowTestsToRun()) 235 if (!AllowTestsToRun())
236 return; 236 return;
237 237
238 content::Shell* tab = CreateNewTab(); 238 content::Shell* tab = CreateNewTab();
239 LoadPage(tab, PAGE_CSS3D, kMemoryLimitMB); 239 LoadPage(tab, PAGE_CSS3D, kMemoryLimitMB);
240 // Make sure that the CSS3D page maxes out a single tab's budget (otherwise 240 // Make sure that the CSS3D page maxes out a single tab's budget (otherwise
241 // the test doesn't test anything) but still stays under the limit. 241 // the test doesn't test anything) but still stays under the limit.
242 EXPECT_TRUE(MemoryUsageInRange( 242 EXPECT_TRUE(MemoryUsageInRange(
243 kSingleTabLimitMB - kWiggleRoomMB, 243 kSingleTabLimitMB - kWiggleRoomMB,
244 kMemoryLimitMB + kWiggleRoomMB)); 244 kMemoryLimitMB + kWiggleRoomMB));
245 } 245 }
246 246
247 } // namespace 247 } // namespace
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_unittest.cc ('k') | content/browser/gpu/gpu_pixel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698