OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/browser/gpu/gpu_data_manager_impl_private.h" | 13 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
14 #include "content/public/browser/gpu_data_manager_observer.h" | 14 #include "content/public/browser/gpu_data_manager_observer.h" |
15 #include "gpu/config/gpu_feature_type.h" | 15 #include "gpu/config/gpu_feature_type.h" |
16 #include "gpu/config/gpu_info.h" | 16 #include "gpu/config/gpu_info.h" |
17 #include "gpu/config/gpu_switches.h" | 17 #include "gpu/config/gpu_switches.h" |
18 #include "gpu/ipc/common/memory_stats.h" | |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
21 | 20 |
22 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
23 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
24 #endif | 23 #endif |
25 | 24 |
26 #define LONG_STRING_CONST(...) #__VA_ARGS__ | 25 #define LONG_STRING_CONST(...) #__VA_ARGS__ |
27 | 26 |
28 namespace content { | 27 namespace content { |
29 namespace { | 28 namespace { |
30 | 29 |
31 class TestObserver : public GpuDataManagerObserver { | 30 class TestObserver : public GpuDataManagerObserver { |
32 public: | 31 public: |
33 TestObserver() | 32 TestObserver() |
34 : gpu_info_updated_(false), | 33 : gpu_info_updated_(false), |
35 video_memory_usage_stats_updated_(false) { | 34 video_memory_usage_stats_updated_(false) { |
36 } | 35 } |
37 ~TestObserver() override {} | 36 ~TestObserver() override {} |
38 | 37 |
39 bool gpu_info_updated() const { return gpu_info_updated_; } | 38 bool gpu_info_updated() const { return gpu_info_updated_; } |
40 bool video_memory_usage_stats_updated() const { | 39 bool video_memory_usage_stats_updated() const { |
41 return video_memory_usage_stats_updated_; | 40 return video_memory_usage_stats_updated_; |
42 } | 41 } |
43 | 42 |
44 void OnGpuInfoUpdate() override { gpu_info_updated_ = true; } | 43 void OnGpuInfoUpdate() override { gpu_info_updated_ = true; } |
45 | 44 |
46 void OnVideoMemoryUsageStatsUpdate( | 45 void OnVideoMemoryUsageStatsUpdate( |
47 const gpu::VideoMemoryUsageStats& stats) override { | 46 const GPUVideoMemoryUsageStats& stats) override { |
48 video_memory_usage_stats_updated_ = true; | 47 video_memory_usage_stats_updated_ = true; |
49 } | 48 } |
50 | 49 |
51 void Reset() { | 50 void Reset() { |
52 gpu_info_updated_ = false; | 51 gpu_info_updated_ = false; |
53 video_memory_usage_stats_updated_ = false; | 52 video_memory_usage_stats_updated_ = false; |
54 } | 53 } |
55 | 54 |
56 private: | 55 private: |
57 bool gpu_info_updated_; | 56 bool gpu_info_updated_; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 349 |
351 TestObserver observer; | 350 TestObserver observer; |
352 manager->AddObserver(&observer); | 351 manager->AddObserver(&observer); |
353 | 352 |
354 { | 353 { |
355 base::RunLoop run_loop; | 354 base::RunLoop run_loop; |
356 run_loop.RunUntilIdle(); | 355 run_loop.RunUntilIdle(); |
357 } | 356 } |
358 EXPECT_FALSE(observer.video_memory_usage_stats_updated()); | 357 EXPECT_FALSE(observer.video_memory_usage_stats_updated()); |
359 | 358 |
360 gpu::VideoMemoryUsageStats vram_stats; | 359 GPUVideoMemoryUsageStats vram_stats; |
361 manager->UpdateVideoMemoryUsageStats(vram_stats); | 360 manager->UpdateVideoMemoryUsageStats(vram_stats); |
362 { | 361 { |
363 base::RunLoop run_loop; | 362 base::RunLoop run_loop; |
364 run_loop.RunUntilIdle(); | 363 run_loop.RunUntilIdle(); |
365 } | 364 } |
366 EXPECT_TRUE(observer.video_memory_usage_stats_updated()); | 365 EXPECT_TRUE(observer.video_memory_usage_stats_updated()); |
367 } | 366 } |
368 | 367 |
369 base::Time GpuDataManagerImplPrivateTest::JustBeforeExpiration( | 368 base::Time GpuDataManagerImplPrivateTest::JustBeforeExpiration( |
370 const GpuDataManagerImplPrivate* manager) { | 369 const GpuDataManagerImplPrivate* manager) { |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 774 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
776 { | 775 { |
777 base::RunLoop run_loop; | 776 base::RunLoop run_loop; |
778 run_loop.RunUntilIdle(); | 777 run_loop.RunUntilIdle(); |
779 } | 778 } |
780 EXPECT_TRUE(observer.gpu_info_updated()); | 779 EXPECT_TRUE(observer.gpu_info_updated()); |
781 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 780 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
782 } | 781 } |
783 | 782 |
784 } // namespace content | 783 } // namespace content |
OLD | NEW |