Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 = 1; | |
| 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 Loading... | |
| 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 14 matching lines...) Expand all Loading... | |
| 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 |
| 124 // TODO(isherman): Verify other data written into the protobuf as a result | 129 // TODO(isherman): Verify other data written into the protobuf as a result |
| 125 // of this call. | 130 // of this call. |
|
Ilya Sherman
2012/08/22 00:40:59
Can you add the appropriate EXPECT check here to v
| |
| 126 } | 131 } |
| 127 }; | 132 }; |
| 128 | 133 |
| 129 TEST_F(MetricsLogTest, RecordEnvironment) { | 134 TEST_F(MetricsLogTest, RecordEnvironment) { |
| 130 // Test that recording the environment works via both of the public methods | 135 // Test that recording the environment works via both of the public methods |
| 131 // RecordEnvironment() and RecordEnvironmentProto(). | 136 // RecordEnvironment() and RecordEnvironmentProto(). |
| 132 TestRecordEnvironment(false); | 137 TestRecordEnvironment(false); |
| 133 TestRecordEnvironment(true); | 138 TestRecordEnvironment(true); |
| 134 } | 139 } |
| 135 | 140 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 EXPECT_NE(std::string::npos, | 300 EXPECT_NE(std::string::npos, |
| 296 encoded.find(" childprocesscrashcount=\"10\"")); | 301 encoded.find(" childprocesscrashcount=\"10\"")); |
| 297 EXPECT_EQ(std::string::npos, | 302 EXPECT_EQ(std::string::npos, |
| 298 encoded.find(" otherusercrashcount=")); | 303 encoded.find(" otherusercrashcount=")); |
| 299 EXPECT_EQ(std::string::npos, | 304 EXPECT_EQ(std::string::npos, |
| 300 encoded.find(" kernelcrashcount=")); | 305 encoded.find(" kernelcrashcount=")); |
| 301 EXPECT_EQ(std::string::npos, | 306 EXPECT_EQ(std::string::npos, |
| 302 encoded.find(" systemuncleanshutdowns=")); | 307 encoded.find(" systemuncleanshutdowns=")); |
| 303 } | 308 } |
| 304 #endif // OS_CHROMEOS | 309 #endif // OS_CHROMEOS |
| OLD | NEW |