| 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/search_engine_settings_collection_view_c
ontroller.h" | 5 #import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_c
ontroller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/search_engines/template_url_service.h" | 13 #include "components/search_engines/template_url_service.h" |
| 14 #include "components/sync_preferences/testing_pref_service_syncable.h" | 14 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 16 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 17 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
| 18 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 18 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
| 19 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" | 19 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" |
| 20 #include "ios/web/public/test/test_web_thread_bundle.h" | 20 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #import "testing/gtest_mac.h" | 22 #import "testing/gtest_mac.h" |
| 23 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." |
| 26 #endif |
| 27 |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 class SearchEngineSettingsCollectionViewControllerTest | 30 class SearchEngineSettingsCollectionViewControllerTest |
| 27 : public CollectionViewControllerTest { | 31 : public CollectionViewControllerTest { |
| 28 protected: | 32 protected: |
| 29 void SetUp() override { | 33 void SetUp() override { |
| 30 CollectionViewControllerTest::SetUp(); | 34 CollectionViewControllerTest::SetUp(); |
| 31 TestChromeBrowserState::Builder test_cbs_builder; | 35 TestChromeBrowserState::Builder test_cbs_builder; |
| 32 test_cbs_builder.AddTestingFactory( | 36 test_cbs_builder.AddTestingFactory( |
| 33 ios::TemplateURLServiceFactory::GetInstance(), | 37 ios::TemplateURLServiceFactory::GetInstance(), |
| 34 ios::TemplateURLServiceFactory::GetDefaultFactory()); | 38 ios::TemplateURLServiceFactory::GetDefaultFactory()); |
| 35 chrome_browser_state_ = test_cbs_builder.Build(); | 39 chrome_browser_state_ = test_cbs_builder.Build(); |
| 36 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(true); | 40 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(true); |
| 37 template_url_service_ = ios::TemplateURLServiceFactory::GetForBrowserState( | 41 template_url_service_ = ios::TemplateURLServiceFactory::GetForBrowserState( |
| 38 chrome_browser_state_.get()); | 42 chrome_browser_state_.get()); |
| 39 template_url_service_->Load(); | 43 template_url_service_->Load(); |
| 40 } | 44 } |
| 41 | 45 |
| 42 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 46 CollectionViewController* InstantiateController() override { |
| 43 return [[SearchEngineSettingsCollectionViewController alloc] | 47 return [[SearchEngineSettingsCollectionViewController alloc] |
| 44 initWithBrowserState:chrome_browser_state_.get()]; | 48 initWithBrowserState:chrome_browser_state_.get()]; |
| 45 } | 49 } |
| 46 | 50 |
| 47 std::unique_ptr<TemplateURL> NewTemplateUrl(const std::string& shortName) { | 51 std::unique_ptr<TemplateURL> NewTemplateUrl(const std::string& shortName) { |
| 48 TemplateURLData data; | 52 TemplateURLData data; |
| 49 data.SetShortName(base::ASCIIToUTF16(shortName)); | 53 data.SetShortName(base::ASCIIToUTF16(shortName)); |
| 50 return std::unique_ptr<TemplateURL>(new TemplateURL(data)); | 54 return std::unique_ptr<TemplateURL>(new TemplateURL(data)); |
| 51 } | 55 } |
| 52 | 56 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 DefaultSearchManager::kDefaultSearchProviderDataPrefName); | 138 DefaultSearchManager::kDefaultSearchProviderDataPrefName); |
| 135 EXPECT_TRUE(searchProviderDict); | 139 EXPECT_TRUE(searchProviderDict); |
| 136 base::string16 shortName; | 140 base::string16 shortName; |
| 137 EXPECT_TRUE(searchProviderDict->GetString(DefaultSearchManager::kShortName, | 141 EXPECT_TRUE(searchProviderDict->GetString(DefaultSearchManager::kShortName, |
| 138 &shortName)); | 142 &shortName)); |
| 139 EXPECT_EQ(url->short_name(), shortName); | 143 EXPECT_EQ(url->short_name(), shortName); |
| 140 CheckModelMatchesTemplateURLs(); | 144 CheckModelMatchesTemplateURLs(); |
| 141 } | 145 } |
| 142 | 146 |
| 143 } // namespace | 147 } // namespace |
| OLD | NEW |