| 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 20 matching lines...) Expand all Loading... |
| 31 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" | 31 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" |
| 32 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 32 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
| 33 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 33 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
| 34 #import "ios/chrome/common/string_util.h" | 34 #import "ios/chrome/common/string_util.h" |
| 35 #include "ios/chrome/grit/ios_strings.h" | 35 #include "ios/chrome/grit/ios_strings.h" |
| 36 #include "ios/web/public/test/test_web_thread_bundle.h" | 36 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 38 #import "testing/gtest_mac.h" | 38 #import "testing/gtest_mac.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 40 | 40 |
| 41 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 42 #error "This file requires ARC support." |
| 43 #endif |
| 44 |
| 41 using testing::Return; | 45 using testing::Return; |
| 42 | 46 |
| 43 @interface ClearBrowsingDataCollectionViewController (ExposedForTesting) | 47 @interface ClearBrowsingDataCollectionViewController (ExposedForTesting) |
| 44 - (NSString*)getCounterTextFromResult: | 48 - (NSString*)getCounterTextFromResult: |
| 45 (const browsing_data::BrowsingDataCounter::Result&)result; | 49 (const browsing_data::BrowsingDataCounter::Result&)result; |
| 46 @end | 50 @end |
| 47 | 51 |
| 48 namespace { | 52 namespace { |
| 49 | 53 |
| 50 enum ItemEnum { | 54 enum ItemEnum { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 std::unique_ptr<sync_preferences::PrefServiceSyncable> CreatePrefService() { | 86 std::unique_ptr<sync_preferences::PrefServiceSyncable> CreatePrefService() { |
| 83 sync_preferences::PrefServiceMockFactory factory; | 87 sync_preferences::PrefServiceMockFactory factory; |
| 84 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 88 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 85 new user_prefs::PrefRegistrySyncable); | 89 new user_prefs::PrefRegistrySyncable); |
| 86 std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs = | 90 std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs = |
| 87 factory.CreateSyncable(registry.get()); | 91 factory.CreateSyncable(registry.get()); |
| 88 RegisterBrowserStatePrefs(registry.get()); | 92 RegisterBrowserStatePrefs(registry.get()); |
| 89 return prefs; | 93 return prefs; |
| 90 } | 94 } |
| 91 | 95 |
| 92 CollectionViewController* NewController() override { | 96 CollectionViewController* InstantiateController() override { |
| 93 return [[ClearBrowsingDataCollectionViewController alloc] | 97 return [[ClearBrowsingDataCollectionViewController alloc] |
| 94 initWithBrowserState:browser_state_.get()]; | 98 initWithBrowserState:browser_state_.get()]; |
| 95 } | 99 } |
| 96 | 100 |
| 97 void SelectItem(int item, int section) { | 101 void SelectItem(int item, int section) { |
| 98 NSIndexPath* indexPath = | 102 NSIndexPath* indexPath = |
| 99 [NSIndexPath indexPathForItem:item inSection:section]; | 103 [NSIndexPath indexPathForItem:item inSection:section]; |
| 100 [controller() collectionView:[controller() collectionView] | 104 [controller() collectionView:[controller() collectionView] |
| 101 didSelectItemAtIndexPath:indexPath]; | 105 didSelectItemAtIndexPath:indexPath]; |
| 102 } | 106 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 controller()); | 301 controller()); |
| 298 for (const TestCase& test_case : kTestCases) { | 302 for (const TestCase& test_case : kTestCases) { |
| 299 browsing_data::BrowsingDataCounter::FinishedResult result( | 303 browsing_data::BrowsingDataCounter::FinishedResult result( |
| 300 &counter, test_case.cache_size); | 304 &counter, test_case.cache_size); |
| 301 NSString* output = [viewController getCounterTextFromResult:result]; | 305 NSString* output = [viewController getCounterTextFromResult:result]; |
| 302 EXPECT_NSEQ(test_case.expected_output, output); | 306 EXPECT_NSEQ(test_case.expected_output, output); |
| 303 } | 307 } |
| 304 } | 308 } |
| 305 | 309 |
| 306 } // namespace | 310 } // namespace |
| OLD | NEW |