Chromium Code Reviews| Index: chrome/browser/metrics/gpu_metrics_provider_unittest.cc |
| diff --git a/chrome/browser/metrics/gpu_metrics_provider_unittest.cc b/chrome/browser/metrics/gpu_metrics_provider_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0d65d9f5753734189356ed479e279c4ed9a7dfe6 |
| --- /dev/null |
| +++ b/chrome/browser/metrics/gpu_metrics_provider_unittest.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/metrics/gpu_metrics_provider.h" |
| + |
| +#include "base/basictypes.h" |
| +#include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/gfx/size.h" |
| + |
| +namespace { |
| + |
| +const int kScreenWidth = 1024; |
| +const int kScreenHeight = 768; |
| +const int kScreenCount = 3; |
| +const float kScreenScaleFactor = 2; |
| + |
| +class TestGPUMetricsProvider : public GPUMetricsProvider { |
| + public: |
| + TestGPUMetricsProvider() {} |
| + |
|
Alexei Svitkine (slow)
2014/05/20 14:16:37
Nit: Remove blank line.
blundell
2014/05/20 14:20:49
Done.
|
| + virtual ~TestGPUMetricsProvider() {} |
| + |
| + private: |
| + virtual gfx::Size GetScreenSize() const OVERRIDE { |
| + return gfx::Size(kScreenWidth, kScreenHeight); |
| + } |
| + |
| + virtual float GetScreenDeviceScaleFactor() const OVERRIDE { |
| + return kScreenScaleFactor; |
| + } |
| + |
| + virtual int GetScreenCount() const OVERRIDE { |
| + return kScreenCount; |
| + } |
| +}; |
|
Alexei Svitkine (slow)
2014/05/20 14:16:37
Nit: Add DISALLOW_COPY_AND_ASSIGN().
blundell
2014/05/20 14:20:49
Done.
|
| + |
| +} // namespace |
| + |
| +class GPUMetricsProviderTest : public testing::Test { |
| + public: |
| + GPUMetricsProviderTest() {} |
| + virtual ~GPUMetricsProviderTest() {} |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GPUMetricsProviderTest); |
|
Alexei Svitkine (slow)
2014/05/20 14:16:37
Nit: Put this in the private section.
blundell
2014/05/20 14:20:49
Done.
|
| +}; |
| + |
| +TEST_F(GPUMetricsProviderTest, ProvideSystemProfileMetrics) { |
| + TestGPUMetricsProvider provider; |
| + metrics::ChromeUserMetricsExtension uma_proto; |
| + |
| + provider.ProvideSystemProfileMetrics(uma_proto.mutable_system_profile()); |
| + |
| + // Check that the system profile has the correct values set. |
| + const metrics::SystemProfileProto::Hardware& hardware = |
| + uma_proto.system_profile().hardware(); |
| + EXPECT_EQ(kScreenWidth, hardware.primary_screen_width()); |
| + EXPECT_EQ(kScreenHeight, hardware.primary_screen_height()); |
| + EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor()); |
| + EXPECT_EQ(kScreenCount, hardware.screen_count()); |
| +} |