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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/port.h" 9 #include "base/port.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 google_util::BrandForTesting brand_for_testing_; 110 google_util::BrandForTesting brand_for_testing_;
111 111
112 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); 112 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog);
113 }; 113 };
114 114
115 } // namespace 115 } // namespace
116 116
117 class MetricsLogTest : public testing::Test { 117 class MetricsLogTest : public testing::Test {
118 public: 118 public:
119 MetricsLogTest() : message_loop_(MessageLoop::TYPE_IO) {} 119 MetricsLogTest() : message_loop_(base::MessageLoop::TYPE_IO) {}
120
120 protected: 121 protected:
121 void TestRecordEnvironment(bool proto_only) { 122 void TestRecordEnvironment(bool proto_only) {
122 TestMetricsLog log(kClientId, kSessionId); 123 TestMetricsLog log(kClientId, kSessionId);
123 124
124 std::vector<webkit::WebPluginInfo> plugins; 125 std::vector<webkit::WebPluginInfo> plugins;
125 GoogleUpdateMetrics google_update_metrics; 126 GoogleUpdateMetrics google_update_metrics;
126 if (proto_only) 127 if (proto_only)
127 log.RecordEnvironmentProto(plugins, google_update_metrics); 128 log.RecordEnvironmentProto(plugins, google_update_metrics);
128 else 129 else
129 log.RecordEnvironment(plugins, google_update_metrics, NULL); 130 log.RecordEnvironment(plugins, google_update_metrics, NULL);
(...skipping 24 matching lines...) Expand all
154 virtual void TearDown() OVERRIDE { 155 virtual void TearDown() OVERRIDE {
155 // Drain the blocking pool from PostTaskAndReply executed by 156 // Drain the blocking pool from PostTaskAndReply executed by
156 // MetrticsLog.network_observer_. 157 // MetrticsLog.network_observer_.
157 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 158 content::BrowserThread::GetBlockingPool()->FlushForTesting();
158 content::RunAllPendingInMessageLoop(); 159 content::RunAllPendingInMessageLoop();
159 } 160 }
160 161
161 private: 162 private:
162 // This is necessary because eventually some tests call base::RepeatingTimer 163 // This is necessary because eventually some tests call base::RepeatingTimer
163 // functions and a message loop is required for that. 164 // functions and a message loop is required for that.
164 MessageLoop message_loop_; 165 base::MessageLoop message_loop_;
165 }; 166 };
166 167
167 TEST_F(MetricsLogTest, RecordEnvironment) { 168 TEST_F(MetricsLogTest, RecordEnvironment) {
168 // Test that recording the environment works via both of the public methods 169 // Test that recording the environment works via both of the public methods
169 // RecordEnvironment() and RecordEnvironmentProto(). 170 // RecordEnvironment() and RecordEnvironmentProto().
170 TestRecordEnvironment(false); 171 TestRecordEnvironment(false);
171 TestRecordEnvironment(true); 172 TestRecordEnvironment(true);
172 } 173 }
173 174
174 // Test that we properly write profiler data to the log. 175 // Test that we properly write profiler data to the log.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 EXPECT_NE(std::string::npos, 334 EXPECT_NE(std::string::npos,
334 encoded.find(" childprocesscrashcount=\"10\"")); 335 encoded.find(" childprocesscrashcount=\"10\""));
335 EXPECT_EQ(std::string::npos, 336 EXPECT_EQ(std::string::npos,
336 encoded.find(" otherusercrashcount=")); 337 encoded.find(" otherusercrashcount="));
337 EXPECT_EQ(std::string::npos, 338 EXPECT_EQ(std::string::npos,
338 encoded.find(" kernelcrashcount=")); 339 encoded.find(" kernelcrashcount="));
339 EXPECT_EQ(std::string::npos, 340 EXPECT_EQ(std::string::npos,
340 encoded.find(" systemuncleanshutdowns=")); 341 encoded.find(" systemuncleanshutdowns="));
341 } 342 }
342 #endif // OS_CHROMEOS 343 #endif // OS_CHROMEOS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698