• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "components/metrics/gpu/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 metrics {
13 
14 namespace {
15 
16 const int kScreenWidth = 1024;
17 const int kScreenHeight = 768;
18 const int kScreenCount = 3;
19 const float kScreenScaleFactor = 2;
20 
21 class TestGPUMetricsProvider : public GPUMetricsProvider {
22  public:
TestGPUMetricsProvider()23   TestGPUMetricsProvider() {}
~TestGPUMetricsProvider()24   virtual ~TestGPUMetricsProvider() {}
25 
26  private:
GetScreenSize() const27   virtual gfx::Size GetScreenSize() const OVERRIDE {
28     return gfx::Size(kScreenWidth, kScreenHeight);
29   }
30 
GetScreenDeviceScaleFactor() const31   virtual float GetScreenDeviceScaleFactor() const OVERRIDE {
32     return kScreenScaleFactor;
33   }
34 
GetScreenCount() const35   virtual int GetScreenCount() const OVERRIDE {
36     return kScreenCount;
37   }
38 
39   DISALLOW_COPY_AND_ASSIGN(TestGPUMetricsProvider);
40 };
41 
42 }  // namespace
43 
44 class GPUMetricsProviderTest : public testing::Test {
45  public:
GPUMetricsProviderTest()46   GPUMetricsProviderTest() {}
~GPUMetricsProviderTest()47   virtual ~GPUMetricsProviderTest() {}
48 
49  private:
50   DISALLOW_COPY_AND_ASSIGN(GPUMetricsProviderTest);
51 };
52 
TEST_F(GPUMetricsProviderTest,ProvideSystemProfileMetrics)53 TEST_F(GPUMetricsProviderTest, ProvideSystemProfileMetrics) {
54   TestGPUMetricsProvider provider;
55   metrics::ChromeUserMetricsExtension uma_proto;
56 
57   provider.ProvideSystemProfileMetrics(uma_proto.mutable_system_profile());
58 
59   // Check that the system profile has the correct values set.
60   const metrics::SystemProfileProto::Hardware& hardware =
61       uma_proto.system_profile().hardware();
62   EXPECT_EQ(kScreenWidth, hardware.primary_screen_width());
63   EXPECT_EQ(kScreenHeight, hardware.primary_screen_height());
64   EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor());
65   EXPECT_EQ(kScreenCount, hardware.screen_count());
66 }
67 
68 }  // namespace metrics
69