| 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/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" |
| 11 #include "content/public/common/content_paths.h" | 11 #include "content/public/common/content_paths.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 15 #include "content/shell/shell.h" | 15 #include "content/shell/shell.h" |
| 16 #include "content/test/content_browser_test.h" | 16 #include "content/test/content_browser_test.h" |
| 17 #include "content/test/content_browser_test_utils.h" | 17 #include "content/test/content_browser_test_utils.h" |
| 18 #include "content/test/gpu/gpu_test_config.h" | |
| 19 #include "gpu/command_buffer/service/gpu_switches.h" | 18 #include "gpu/command_buffer/service/gpu_switches.h" |
| 19 #include "gpu/config/gpu_test_config.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 // Run the tests with a memory limit of 256MB, and give | 24 // Run the tests with a memory limit of 256MB, and give |
| 25 // and extra 4MB of wiggle-room for over-allocation. | 25 // and extra 4MB of wiggle-room for over-allocation. |
| 26 const char* kMemoryLimitMBSwitch = "256"; | 26 const char* kMemoryLimitMBSwitch = "256"; |
| 27 const size_t kMemoryLimitMB = 256; | 27 const size_t kMemoryLimitMB = 256; |
| 28 const size_t kSingleTabLimitMB = 128; | 28 const size_t kSingleTabLimitMB = 128; |
| 29 const size_t kWiggleRoomMB = 4; | 29 const size_t kWiggleRoomMB = 4; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 47 size_t GetBytesAllocated() { | 47 size_t GetBytesAllocated() { |
| 48 message_loop_runner_ = new MessageLoopRunner; | 48 message_loop_runner_ = new MessageLoopRunner; |
| 49 GpuDataManager::GetInstance()->AddObserver(this); | 49 GpuDataManager::GetInstance()->AddObserver(this); |
| 50 GpuDataManager::GetInstance()->RequestVideoMemoryUsageStatsUpdate(); | 50 GpuDataManager::GetInstance()->RequestVideoMemoryUsageStatsUpdate(); |
| 51 message_loop_runner_->Run(); | 51 message_loop_runner_->Run(); |
| 52 GpuDataManager::GetInstance()->RemoveObserver(this); | 52 GpuDataManager::GetInstance()->RemoveObserver(this); |
| 53 message_loop_runner_ = NULL; | 53 message_loop_runner_ = NULL; |
| 54 return bytes_allocated_; | 54 return bytes_allocated_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 |
| 57 private: | 58 private: |
| 58 size_t bytes_allocated_; | 59 size_t bytes_allocated_; |
| 59 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 60 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 class GpuMemoryTest : public ContentBrowserTest { | 63 class GpuMemoryTest : public ContentBrowserTest { |
| 63 public: | 64 public: |
| 64 GpuMemoryTest() | 65 GpuMemoryTest() |
| 65 : allow_tests_to_run_(false), | 66 : allow_tests_to_run_(false), |
| 66 has_used_first_shell_(false) { | 67 has_used_first_shell_(false) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 Shell* tab = CreateNewTab(); | 225 Shell* tab = CreateNewTab(); |
| 225 LoadPage(tab, PAGE_CSS3D, kMemoryLimitMB); | 226 LoadPage(tab, PAGE_CSS3D, kMemoryLimitMB); |
| 226 // Make sure that the CSS3D page maxes out a single tab's budget (otherwise | 227 // Make sure that the CSS3D page maxes out a single tab's budget (otherwise |
| 227 // the test doesn't test anything) but still stays under the limit. | 228 // the test doesn't test anything) but still stays under the limit. |
| 228 EXPECT_TRUE(MemoryUsageInRange( | 229 EXPECT_TRUE(MemoryUsageInRange( |
| 229 kSingleTabLimitMB - kWiggleRoomMB, | 230 kSingleTabLimitMB - kWiggleRoomMB, |
| 230 kMemoryLimitMB + kWiggleRoomMB)); | 231 kMemoryLimitMB + kWiggleRoomMB)); |
| 231 } | 232 } |
| 232 | 233 |
| 233 } // namespace content | 234 } // namespace content |
| OLD | NEW |