| OLD | NEW |
| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeletePasswords)); | 227 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeletePasswords)); |
| 228 SelectItem(kDeleteFormDataItem, section); | 228 SelectItem(kDeleteFormDataItem, section); |
| 229 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteFormData)); | 229 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteFormData)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 TEST_F(ClearBrowsingDataCollectionViewControllerTest, | 232 TEST_F(ClearBrowsingDataCollectionViewControllerTest, |
| 233 TestCacheCounterFormattingForAllTime) { | 233 TestCacheCounterFormattingForAllTime) { |
| 234 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); | 234 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); |
| 235 PrefService* prefs = browser_state_->GetPrefs(); | 235 PrefService* prefs = browser_state_->GetPrefs(); |
| 236 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, | 236 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, |
| 237 browsing_data::ALL_TIME); | 237 static_cast<int>(browsing_data::TimePeriod::ALL_TIME)); |
| 238 CacheCounter counter(browser_state_.get()); | 238 CacheCounter counter(browser_state_.get()); |
| 239 | 239 |
| 240 // Test multiple possible types of formatting. | 240 // Test multiple possible types of formatting. |
| 241 // clang-format off | 241 // clang-format off |
| 242 const struct TestCase { | 242 const struct TestCase { |
| 243 int cache_size; | 243 int cache_size; |
| 244 NSString* expected_output; | 244 NSString* expected_output; |
| 245 } kTestCases[] = { | 245 } kTestCases[] = { |
| 246 {0, @"less than 1 MB"}, | 246 {0, @"less than 1 MB"}, |
| 247 {(1 << 20) - 1, @"less than 1 MB"}, | 247 {(1 << 20) - 1, @"less than 1 MB"}, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 267 TestCacheCounterFormattingForLessThanAllTime) { | 267 TestCacheCounterFormattingForLessThanAllTime) { |
| 268 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); | 268 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); |
| 269 | 269 |
| 270 // If the new UI is not enabled then the pref value for the time period | 270 // If the new UI is not enabled then the pref value for the time period |
| 271 // is ignored and the time period defaults to ALL_TIME. | 271 // is ignored and the time period defaults to ALL_TIME. |
| 272 if (!experimental_flags::IsNewClearBrowsingDataUIEnabled()) { | 272 if (!experimental_flags::IsNewClearBrowsingDataUIEnabled()) { |
| 273 return; | 273 return; |
| 274 } | 274 } |
| 275 PrefService* prefs = browser_state_->GetPrefs(); | 275 PrefService* prefs = browser_state_->GetPrefs(); |
| 276 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, | 276 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, |
| 277 browsing_data::LAST_HOUR); | 277 static_cast<int>(browsing_data::TimePeriod::LAST_HOUR)); |
| 278 CacheCounter counter(browser_state_.get()); | 278 CacheCounter counter(browser_state_.get()); |
| 279 | 279 |
| 280 // Test multiple possible types of formatting. | 280 // Test multiple possible types of formatting. |
| 281 // clang-format off | 281 // clang-format off |
| 282 const struct TestCase { | 282 const struct TestCase { |
| 283 int cache_size; | 283 int cache_size; |
| 284 NSString* expected_output; | 284 NSString* expected_output; |
| 285 } kTestCases[] = { | 285 } kTestCases[] = { |
| 286 {0, @"less than 1 MB"}, | 286 {0, @"less than 1 MB"}, |
| 287 {(1 << 20) - 1, @"less than 1 MB"}, | 287 {(1 << 20) - 1, @"less than 1 MB"}, |
| 288 {(1 << 20), @"less than 1 MB"}, | 288 {(1 << 20), @"less than 1 MB"}, |
| 289 {(1 << 20) + (1 << 19), @"less than 1.5 MB"}, | 289 {(1 << 20) + (1 << 19), @"less than 1.5 MB"}, |
| 290 {(1 << 21), @"less than 2 MB"}, | 290 {(1 << 21), @"less than 2 MB"}, |
| 291 {(1 << 30), @"less than 1 GB"} | 291 {(1 << 30), @"less than 1 GB"} |
| 292 }; | 292 }; |
| 293 // clang-format on | 293 // clang-format on |
| 294 | 294 |
| 295 ClearBrowsingDataCollectionViewController* viewController = | 295 ClearBrowsingDataCollectionViewController* viewController = |
| 296 base::mac::ObjCCastStrict<ClearBrowsingDataCollectionViewController>( | 296 base::mac::ObjCCastStrict<ClearBrowsingDataCollectionViewController>( |
| 297 controller()); | 297 controller()); |
| 298 for (const TestCase& test_case : kTestCases) { | 298 for (const TestCase& test_case : kTestCases) { |
| 299 browsing_data::BrowsingDataCounter::FinishedResult result( | 299 browsing_data::BrowsingDataCounter::FinishedResult result( |
| 300 &counter, test_case.cache_size); | 300 &counter, test_case.cache_size); |
| 301 NSString* output = [viewController getCounterTextFromResult:result]; | 301 NSString* output = [viewController getCounterTextFromResult:result]; |
| 302 EXPECT_NSEQ(test_case.expected_output, output); | 302 EXPECT_NSEQ(test_case.expected_output, output); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace | 306 } // namespace |
| OLD | NEW |