Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/metrics/metrics_log_unittest.cc

Issue 10825485: Record device scale factor in the metrics log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/common/metrics/proto/system_profile.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/port.h" 8 #include "base/port.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 18 matching lines...) Expand all
29 using tracked_objects::ProcessDataSnapshot; 29 using tracked_objects::ProcessDataSnapshot;
30 using tracked_objects::TaskSnapshot; 30 using tracked_objects::TaskSnapshot;
31 31
32 namespace { 32 namespace {
33 33
34 const char kClientId[] = "bogus client ID"; 34 const char kClientId[] = "bogus client ID";
35 const int kSessionId = 127; 35 const int kSessionId = 127;
36 const int kScreenWidth = 1024; 36 const int kScreenWidth = 1024;
37 const int kScreenHeight = 768; 37 const int kScreenHeight = 768;
38 const int kScreenCount = 3; 38 const int kScreenCount = 3;
39 const float kScreenScaleFactor = 2;
39 const chrome_variations::SelectedGroupId kFieldTrialIds[] = { 40 const chrome_variations::SelectedGroupId kFieldTrialIds[] = {
40 {37, 43}, 41 {37, 43},
41 {13, 47}, 42 {13, 47},
42 {23, 17} 43 {23, 17}
43 }; 44 };
44 45
45 class TestMetricsLog : public MetricsLog { 46 class TestMetricsLog : public MetricsLog {
46 public: 47 public:
47 TestMetricsLog(const std::string& client_id, int session_id) 48 TestMetricsLog(const std::string& client_id, int session_id)
48 : MetricsLog(client_id, session_id) { 49 : MetricsLog(client_id, session_id) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { 83 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) {
83 field_trial_ids->push_back(kFieldTrialIds[i]); 84 field_trial_ids->push_back(kFieldTrialIds[i]);
84 } 85 }
85 } 86 }
86 87
87 virtual gfx::Size GetScreenSize() const OVERRIDE { 88 virtual gfx::Size GetScreenSize() const OVERRIDE {
88 return gfx::Size(kScreenWidth, kScreenHeight); 89 return gfx::Size(kScreenWidth, kScreenHeight);
89 } 90 }
90 91
92 virtual float GetScreenDeviceScaleFactor() const OVERRIDE {
93 return kScreenScaleFactor;
94 }
95
91 virtual int GetScreenCount() const OVERRIDE { 96 virtual int GetScreenCount() const OVERRIDE {
92 return kScreenCount; 97 return kScreenCount;
93 } 98 }
94 99
95 TestingPrefService prefs_; 100 TestingPrefService prefs_;
96 101
97 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); 102 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog);
98 }; 103 };
99 104
100 } // namespace 105 } // namespace
(...skipping 13 matching lines...) Expand all
114 const metrics::SystemProfileProto& system_profile = log.system_profile(); 119 const metrics::SystemProfileProto& system_profile = log.system_profile();
115 ASSERT_EQ(arraysize(kFieldTrialIds), 120 ASSERT_EQ(arraysize(kFieldTrialIds),
116 static_cast<size_t>(system_profile.field_trial_size())); 121 static_cast<size_t>(system_profile.field_trial_size()));
117 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { 122 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) {
118 const metrics::SystemProfileProto::FieldTrial& field_trial = 123 const metrics::SystemProfileProto::FieldTrial& field_trial =
119 system_profile.field_trial(i); 124 system_profile.field_trial(i);
120 EXPECT_EQ(kFieldTrialIds[i].name, field_trial.name_id()); 125 EXPECT_EQ(kFieldTrialIds[i].name, field_trial.name_id());
121 EXPECT_EQ(kFieldTrialIds[i].group, field_trial.group_id()); 126 EXPECT_EQ(kFieldTrialIds[i].group, field_trial.group_id());
122 } 127 }
123 128
129 const metrics::SystemProfileProto::Hardware& hardware =
130 system_profile.hardware();
131 EXPECT_EQ(kScreenWidth, hardware.primary_screen_width());
132 EXPECT_EQ(kScreenHeight, hardware.primary_screen_height());
133 EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor());
134 EXPECT_EQ(kScreenCount, hardware.screen_count());
135
124 // TODO(isherman): Verify other data written into the protobuf as a result 136 // TODO(isherman): Verify other data written into the protobuf as a result
125 // of this call. 137 // of this call.
126 } 138 }
127 }; 139 };
128 140
129 TEST_F(MetricsLogTest, RecordEnvironment) { 141 TEST_F(MetricsLogTest, RecordEnvironment) {
130 // Test that recording the environment works via both of the public methods 142 // Test that recording the environment works via both of the public methods
131 // RecordEnvironment() and RecordEnvironmentProto(). 143 // RecordEnvironment() and RecordEnvironmentProto().
132 TestRecordEnvironment(false); 144 TestRecordEnvironment(false);
133 TestRecordEnvironment(true); 145 TestRecordEnvironment(true);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 EXPECT_NE(std::string::npos, 307 EXPECT_NE(std::string::npos,
296 encoded.find(" childprocesscrashcount=\"10\"")); 308 encoded.find(" childprocesscrashcount=\"10\""));
297 EXPECT_EQ(std::string::npos, 309 EXPECT_EQ(std::string::npos,
298 encoded.find(" otherusercrashcount=")); 310 encoded.find(" otherusercrashcount="));
299 EXPECT_EQ(std::string::npos, 311 EXPECT_EQ(std::string::npos,
300 encoded.find(" kernelcrashcount=")); 312 encoded.find(" kernelcrashcount="));
301 EXPECT_EQ(std::string::npos, 313 EXPECT_EQ(std::string::npos,
302 encoded.find(" systemuncleanshutdowns=")); 314 encoded.find(" systemuncleanshutdowns="));
303 } 315 }
304 #endif // OS_CHROMEOS 316 #endif // OS_CHROMEOS
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/common/metrics/proto/system_profile.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698