| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "chrome/browser/metrics/gpu_metrics_provider.h" | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "ui/gfx/size.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 const int kScreenWidth = 1024; | |
| 15 const int kScreenHeight = 768; | |
| 16 const int kScreenCount = 3; | |
| 17 const float kScreenScaleFactor = 2; | |
| 18 | |
| 19 class TestGPUMetricsProvider : public GPUMetricsProvider { | |
| 20 public: | |
| 21 TestGPUMetricsProvider() {} | |
| 22 virtual ~TestGPUMetricsProvider() {} | |
| 23 | |
| 24 private: | |
| 25 virtual gfx::Size GetScreenSize() const OVERRIDE { | |
| 26 return gfx::Size(kScreenWidth, kScreenHeight); | |
| 27 } | |
| 28 | |
| 29 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { | |
| 30 return kScreenScaleFactor; | |
| 31 } | |
| 32 | |
| 33 virtual int GetScreenCount() const OVERRIDE { | |
| 34 return kScreenCount; | |
| 35 } | |
| 36 | |
| 37 DISALLOW_COPY_AND_ASSIGN(TestGPUMetricsProvider); | |
| 38 }; | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 42 class GPUMetricsProviderTest : public testing::Test { | |
| 43 public: | |
| 44 GPUMetricsProviderTest() {} | |
| 45 virtual ~GPUMetricsProviderTest() {} | |
| 46 | |
| 47 private: | |
| 48 DISALLOW_COPY_AND_ASSIGN(GPUMetricsProviderTest); | |
| 49 }; | |
| 50 | |
| 51 TEST_F(GPUMetricsProviderTest, ProvideSystemProfileMetrics) { | |
| 52 TestGPUMetricsProvider provider; | |
| 53 metrics::ChromeUserMetricsExtension uma_proto; | |
| 54 | |
| 55 provider.ProvideSystemProfileMetrics(uma_proto.mutable_system_profile()); | |
| 56 | |
| 57 // Check that the system profile has the correct values set. | |
| 58 const metrics::SystemProfileProto::Hardware& hardware = | |
| 59 uma_proto.system_profile().hardware(); | |
| 60 EXPECT_EQ(kScreenWidth, hardware.primary_screen_width()); | |
| 61 EXPECT_EQ(kScreenHeight, hardware.primary_screen_height()); | |
| 62 EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor()); | |
| 63 EXPECT_EQ(kScreenCount, hardware.screen_count()); | |
| 64 } | |
| OLD | NEW |