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

Side by Side Diff: ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller_unittest.mm

Issue 2910983002: Improve and fix counter texts (Closed)
Patch Set: fix ios failures, add random change to browsing_data_utils.h to trigger all tests Created 3 years, 6 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
« no previous file with comments | « components/browsing_data_strings.grdp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h" 5 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, 240 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod,
241 static_cast<int>(browsing_data::TimePeriod::ALL_TIME)); 241 static_cast<int>(browsing_data::TimePeriod::ALL_TIME));
242 CacheCounter counter(browser_state_.get()); 242 CacheCounter counter(browser_state_.get());
243 243
244 // Test multiple possible types of formatting. 244 // Test multiple possible types of formatting.
245 // clang-format off 245 // clang-format off
246 const struct TestCase { 246 const struct TestCase {
247 int cache_size; 247 int cache_size;
248 NSString* expected_output; 248 NSString* expected_output;
249 } kTestCases[] = { 249 } kTestCases[] = {
250 {0, @"less than 1 MB"}, 250 {0, @"Less than 1 MB"},
251 {(1 << 20) - 1, @"less than 1 MB"}, 251 {(1 << 20) - 1, @"Less than 1 MB"},
252 {(1 << 20), @"1 MB"}, 252 {(1 << 20), @"1 MB"},
253 {(1 << 20) + (1 << 19), @"1.5 MB"}, 253 {(1 << 20) + (1 << 19), @"1.5 MB"},
254 {(1 << 21), @"2 MB"}, 254 {(1 << 21), @"2 MB"},
255 {(1 << 30), @"1 GB"} 255 {(1 << 30), @"1 GB"}
256 }; 256 };
257 // clang-format on 257 // clang-format on
258 258
259 ClearBrowsingDataCollectionViewController* viewController = 259 ClearBrowsingDataCollectionViewController* viewController =
260 base::mac::ObjCCastStrict<ClearBrowsingDataCollectionViewController>( 260 base::mac::ObjCCastStrict<ClearBrowsingDataCollectionViewController>(
261 controller()); 261 controller());
(...skipping 18 matching lines...) Expand all
280 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, 280 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod,
281 static_cast<int>(browsing_data::TimePeriod::LAST_HOUR)); 281 static_cast<int>(browsing_data::TimePeriod::LAST_HOUR));
282 CacheCounter counter(browser_state_.get()); 282 CacheCounter counter(browser_state_.get());
283 283
284 // Test multiple possible types of formatting. 284 // Test multiple possible types of formatting.
285 // clang-format off 285 // clang-format off
286 const struct TestCase { 286 const struct TestCase {
287 int cache_size; 287 int cache_size;
288 NSString* expected_output; 288 NSString* expected_output;
289 } kTestCases[] = { 289 } kTestCases[] = {
290 {0, @"less than 1 MB"}, 290 {0, @"Less than 1 MB"},
291 {(1 << 20) - 1, @"less than 1 MB"}, 291 {(1 << 20) - 1, @"Less than 1 MB"},
292 {(1 << 20), @"less than 1 MB"}, 292 {(1 << 20), @"Less than 1 MB"},
293 {(1 << 20) + (1 << 19), @"less than 1.5 MB"}, 293 {(1 << 20) + (1 << 19), @"Less than 1.5 MB"},
294 {(1 << 21), @"less than 2 MB"}, 294 {(1 << 21), @"Less than 2 MB"},
295 {(1 << 30), @"less than 1 GB"} 295 {(1 << 30), @"Less than 1 GB"}
296 }; 296 };
297 // clang-format on 297 // clang-format on
298 298
299 ClearBrowsingDataCollectionViewController* viewController = 299 ClearBrowsingDataCollectionViewController* viewController =
300 base::mac::ObjCCastStrict<ClearBrowsingDataCollectionViewController>( 300 base::mac::ObjCCastStrict<ClearBrowsingDataCollectionViewController>(
301 controller()); 301 controller());
302 for (const TestCase& test_case : kTestCases) { 302 for (const TestCase& test_case : kTestCases) {
303 browsing_data::BrowsingDataCounter::FinishedResult result( 303 browsing_data::BrowsingDataCounter::FinishedResult result(
304 &counter, test_case.cache_size); 304 &counter, test_case.cache_size);
305 NSString* output = [viewController getCounterTextFromResult:result]; 305 NSString* output = [viewController getCounterTextFromResult:result];
306 EXPECT_NSEQ(test_case.expected_output, output); 306 EXPECT_NSEQ(test_case.expected_output, output);
307 } 307 }
308 } 308 }
309 309
310 } // namespace 310 } // namespace
OLDNEW
« no previous file with comments | « components/browsing_data_strings.grdp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698