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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
26 #endif | 26 #endif |
27 | 27 |
28 #define LONG_STRING_CONST(...) #__VA_ARGS__ | 28 #define LONG_STRING_CONST(...) #__VA_ARGS__ |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 namespace { | 31 namespace { |
32 | 32 |
33 class TestObserver : public GpuDataManagerObserver { | 33 class TestObserver : public GpuDataManagerObserver { |
34 public: | 34 public: |
35 TestObserver() | 35 TestObserver() {} |
36 : gpu_info_updated_(false), | |
37 video_memory_usage_stats_updated_(false) { | |
38 } | |
39 ~TestObserver() override {} | 36 ~TestObserver() override {} |
40 | 37 |
41 bool gpu_info_updated() const { return gpu_info_updated_; } | 38 bool gpu_info_updated() const { return gpu_info_updated_; } |
42 bool video_memory_usage_stats_updated() const { | |
43 return video_memory_usage_stats_updated_; | |
44 } | |
45 | 39 |
46 void OnGpuInfoUpdate() override { gpu_info_updated_ = true; } | 40 void OnGpuInfoUpdate() override { gpu_info_updated_ = true; } |
47 | 41 |
48 void OnVideoMemoryUsageStatsUpdate( | |
49 const gpu::VideoMemoryUsageStats& stats) override { | |
50 video_memory_usage_stats_updated_ = true; | |
51 } | |
52 | |
53 void Reset() { | 42 void Reset() { |
54 gpu_info_updated_ = false; | 43 gpu_info_updated_ = false; |
55 video_memory_usage_stats_updated_ = false; | |
56 } | 44 } |
57 | 45 |
58 private: | 46 private: |
59 bool gpu_info_updated_; | 47 bool gpu_info_updated_ = false; |
60 bool video_memory_usage_stats_updated_; | |
61 }; | 48 }; |
62 | 49 |
63 static base::Time GetTimeForTesting() { | 50 static base::Time GetTimeForTesting() { |
64 return base::Time::FromDoubleT(1000); | 51 return base::Time::FromDoubleT(1000); |
65 } | 52 } |
66 | 53 |
67 static GURL GetDomain1ForTesting() { | 54 static GURL GetDomain1ForTesting() { |
68 return GURL("http://foo.com/"); | 55 return GURL("http://foo.com/"); |
69 } | 56 } |
70 | 57 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 run_loop.RunUntilIdle(); | 384 run_loop.RunUntilIdle(); |
398 } | 385 } |
399 if (manager->ShouldUseSwiftShader()) { | 386 if (manager->ShouldUseSwiftShader()) { |
400 // Once SwiftShader is enabled, the gpu info can no longer be updated | 387 // Once SwiftShader is enabled, the gpu info can no longer be updated |
401 EXPECT_FALSE(observer.gpu_info_updated()); | 388 EXPECT_FALSE(observer.gpu_info_updated()); |
402 } else { | 389 } else { |
403 EXPECT_TRUE(observer.gpu_info_updated()); | 390 EXPECT_TRUE(observer.gpu_info_updated()); |
404 } | 391 } |
405 } | 392 } |
406 | 393 |
407 TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) { | |
408 ScopedGpuDataManagerImpl manager; | |
409 | |
410 TestObserver observer; | |
411 manager->AddObserver(&observer); | |
412 | |
413 { | |
414 base::RunLoop run_loop; | |
415 run_loop.RunUntilIdle(); | |
416 } | |
417 EXPECT_FALSE(observer.video_memory_usage_stats_updated()); | |
418 | |
419 gpu::VideoMemoryUsageStats vram_stats; | |
420 manager->UpdateVideoMemoryUsageStats(vram_stats); | |
421 { | |
422 base::RunLoop run_loop; | |
423 run_loop.RunUntilIdle(); | |
424 } | |
425 EXPECT_TRUE(observer.video_memory_usage_stats_updated()); | |
426 } | |
427 | |
428 base::Time GpuDataManagerImplPrivateTest::JustBeforeExpiration( | 394 base::Time GpuDataManagerImplPrivateTest::JustBeforeExpiration( |
429 const GpuDataManagerImplPrivate* manager) { | 395 const GpuDataManagerImplPrivate* manager) { |
430 return GetTimeForTesting() + base::TimeDelta::FromMilliseconds( | 396 return GetTimeForTesting() + base::TimeDelta::FromMilliseconds( |
431 manager->GetBlockAllDomainsDurationInMs()) - | 397 manager->GetBlockAllDomainsDurationInMs()) - |
432 base::TimeDelta::FromMilliseconds(3); | 398 base::TimeDelta::FromMilliseconds(3); |
433 } | 399 } |
434 | 400 |
435 base::Time GpuDataManagerImplPrivateTest::JustAfterExpiration( | 401 base::Time GpuDataManagerImplPrivateTest::JustAfterExpiration( |
436 const GpuDataManagerImplPrivate* manager) { | 402 const GpuDataManagerImplPrivate* manager) { |
437 return GetTimeForTesting() + base::TimeDelta::FromMilliseconds( | 403 return GetTimeForTesting() + base::TimeDelta::FromMilliseconds( |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 EXPECT_TRUE(observer.gpu_info_updated()); | 793 EXPECT_TRUE(observer.gpu_info_updated()); |
828 if (manager->ShouldUseSwiftShader()) { | 794 if (manager->ShouldUseSwiftShader()) { |
829 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 795 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
830 manager->GetBlacklistedFeatureCount()); | 796 manager->GetBlacklistedFeatureCount()); |
831 } else { | 797 } else { |
832 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 798 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
833 } | 799 } |
834 } | 800 } |
835 | 801 |
836 } // namespace content | 802 } // namespace content |
OLD | NEW |