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

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

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 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_service.cc ('k') | chrome/browser/net/predictor.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/metrics/metrics_service.h" 5 #include "chrome/browser/metrics/metrics_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 TEST(MetricsServiceTest, CorruptSizeOfLogList) { 164 TEST(MetricsServiceTest, CorruptSizeOfLogList) {
165 ListValue list; 165 ListValue list;
166 std::vector<std::string> local_list; 166 std::vector<std::string> local_list;
167 167
168 local_list.push_back("Hello world!"); 168 local_list.push_back("Hello world!");
169 EXPECT_EQ(1U, local_list.size()); 169 EXPECT_EQ(1U, local_list.size());
170 MetricsService::StoreUnsentLogsHelper(local_list, kMaxLocalListSize, &list); 170 MetricsService::StoreUnsentLogsHelper(local_list, kMaxLocalListSize, &list);
171 EXPECT_EQ(3U, list.GetSize()); 171 EXPECT_EQ(3U, list.GetSize());
172 172
173 // Change list size from 1 to 2. 173 // Change list size from 1 to 2.
174 EXPECT_TRUE(list.Set(0, Value::CreateIntegerValue(2))); 174 EXPECT_TRUE(list.Set(0, base::NumberValue::New(2)));
175 EXPECT_EQ(3U, list.GetSize()); 175 EXPECT_EQ(3U, list.GetSize());
176 176
177 local_list.clear(); 177 local_list.clear();
178 EXPECT_EQ(MetricsService::LIST_SIZE_CORRUPTION, 178 EXPECT_EQ(MetricsService::LIST_SIZE_CORRUPTION,
179 MetricsService::RecallUnsentLogsHelper(list, &local_list)); 179 MetricsService::RecallUnsentLogsHelper(list, &local_list));
180 } 180 }
181 181
182 // Corrupt checksum of stored list. 182 // Corrupt checksum of stored list.
183 TEST(MetricsServiceTest, CorruptChecksumOfLogList) { 183 TEST(MetricsServiceTest, CorruptChecksumOfLogList) {
184 ListValue list; 184 ListValue list;
185 std::vector<std::string> local_list; 185 std::vector<std::string> local_list;
186 186
187 local_list.clear(); 187 local_list.clear();
188 local_list.push_back("Hello world!"); 188 local_list.push_back("Hello world!");
189 EXPECT_EQ(1U, local_list.size()); 189 EXPECT_EQ(1U, local_list.size());
190 MetricsService::StoreUnsentLogsHelper(local_list, kMaxLocalListSize, &list); 190 MetricsService::StoreUnsentLogsHelper(local_list, kMaxLocalListSize, &list);
191 EXPECT_EQ(3U, list.GetSize()); 191 EXPECT_EQ(3U, list.GetSize());
192 192
193 // Fetch checksum (last element) and change it. 193 // Fetch checksum (last element) and change it.
194 std::string checksum; 194 std::string checksum;
195 EXPECT_TRUE((*(list.end() - 1))->GetAsString(&checksum)); 195 EXPECT_TRUE((*(list.end() - 1))->GetAsString(&checksum));
196 checksum[0] = (checksum[0] == 'a') ? 'b' : 'a'; 196 checksum[0] = (checksum[0] == 'a') ? 'b' : 'a';
197 EXPECT_TRUE(list.Set(2, Value::CreateStringValue(checksum))); 197 EXPECT_TRUE(list.Set(2, base::StringValue::New(checksum)));
198 EXPECT_EQ(3U, list.GetSize()); 198 EXPECT_EQ(3U, list.GetSize());
199 199
200 local_list.clear(); 200 local_list.clear();
201 EXPECT_EQ(MetricsService::CHECKSUM_CORRUPTION, 201 EXPECT_EQ(MetricsService::CHECKSUM_CORRUPTION,
202 MetricsService::RecallUnsentLogsHelper(list, &local_list)); 202 MetricsService::RecallUnsentLogsHelper(list, &local_list));
203 } 203 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698