| 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 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "components/search_engines/template_url_service.h" | 9 #include "components/search_engines/template_url_service.h" |
| 10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 11 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 12 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" | 12 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" |
| 13 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" | |
| 14 #import "ios/chrome/browser/ui/ntp/google_landing_mediator.h" | 13 #import "ios/chrome/browser/ui/ntp/google_landing_mediator.h" |
| 14 #import "ios/chrome/browser/ui/ntp/google_landing_view_controller.h" |
| 15 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" | 15 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" |
| 16 #include "ios/chrome/browser/web_state_list/web_state_list.h" | 16 #include "ios/chrome/browser/web_state_list/web_state_list.h" |
| 17 #include "ios/chrome/test/block_cleanup_test.h" | 17 #include "ios/chrome/test/block_cleanup_test.h" |
| 18 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" | 18 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" |
| 19 #include "ios/web/public/test/test_web_thread.h" | 19 #include "ios/web/public/test/test_web_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "testing/gtest_mac.h" | 21 #include "testing/gtest_mac.h" |
| 22 #import "third_party/ocmock/OCMock/OCMock.h" | 22 #import "third_party/ocmock/OCMock/OCMock.h" |
| 23 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) | 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." | 25 #error "This file requires ARC support." |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class GoogleLandingControllerTest : public BlockCleanupTest { | 30 class GoogleLandingViewControllerTest : public BlockCleanupTest { |
| 31 public: | 31 public: |
| 32 GoogleLandingControllerTest() | 32 GoogleLandingViewControllerTest() |
| 33 : ui_thread_(web::WebThread::UI, &message_loop_), | 33 : ui_thread_(web::WebThread::UI, &message_loop_), |
| 34 io_thread_(web::WebThread::IO, &message_loop_) {} | 34 io_thread_(web::WebThread::IO, &message_loop_) {} |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 void SetUp() override { | 37 void SetUp() override { |
| 38 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 38 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 39 | 39 |
| 40 TestChromeBrowserState::Builder test_cbs_builder; | 40 TestChromeBrowserState::Builder test_cbs_builder; |
| 41 test_cbs_builder.AddTestingFactory( | 41 test_cbs_builder.AddTestingFactory( |
| 42 IOSChromeTabRestoreServiceFactory::GetInstance(), | 42 IOSChromeTabRestoreServiceFactory::GetInstance(), |
| 43 IOSChromeTabRestoreServiceFactory::GetDefaultFactory()); | 43 IOSChromeTabRestoreServiceFactory::GetDefaultFactory()); |
| 44 test_cbs_builder.AddTestingFactory( | 44 test_cbs_builder.AddTestingFactory( |
| 45 ios::TemplateURLServiceFactory::GetInstance(), | 45 ios::TemplateURLServiceFactory::GetInstance(), |
| 46 ios::TemplateURLServiceFactory::GetDefaultFactory()); | 46 ios::TemplateURLServiceFactory::GetDefaultFactory()); |
| 47 | 47 |
| 48 chrome_browser_state_ = test_cbs_builder.Build(); | 48 chrome_browser_state_ = test_cbs_builder.Build(); |
| 49 BlockCleanupTest::SetUp(); | 49 BlockCleanupTest::SetUp(); |
| 50 | 50 |
| 51 // Set up tab restore service. | 51 // Set up tab restore service. |
| 52 TemplateURLService* template_url_service = | 52 TemplateURLService* template_url_service = |
| 53 ios::TemplateURLServiceFactory::GetForBrowserState( | 53 ios::TemplateURLServiceFactory::GetForBrowserState( |
| 54 chrome_browser_state_.get()); | 54 chrome_browser_state_.get()); |
| 55 template_url_service->Load(); | 55 template_url_service->Load(); |
| 56 | 56 |
| 57 // Set up stub UrlLoader. | 57 // Set up stub UrlLoader. |
| 58 mockUrlLoader_ = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; | 58 mockUrlLoader_ = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; |
| 59 controller_ = [[GoogleLandingController alloc] init]; | 59 controller_ = [[GoogleLandingViewController alloc] init]; |
| 60 webStateList_ = base::MakeUnique<WebStateList>(&webStateListDelegate_); | 60 webStateList_ = base::MakeUnique<WebStateList>(&webStateListDelegate_); |
| 61 mediator_ = [[GoogleLandingMediator alloc] | 61 mediator_ = [[GoogleLandingMediator alloc] |
| 62 initWithConsumer:controller_ | 62 initWithConsumer:controller_ |
| 63 browserState:chrome_browser_state_.get() | 63 browserState:chrome_browser_state_.get() |
| 64 dispatcher:nil | 64 dispatcher:nil |
| 65 webStateList:webStateList_.get()]; | 65 webStateList:webStateList_.get()]; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 void TearDown() override { [mediator_ shutdown]; } | 68 void TearDown() override { [mediator_ shutdown]; } |
| 69 | 69 |
| 70 base::MessageLoopForUI message_loop_; | 70 base::MessageLoopForUI message_loop_; |
| 71 web::TestWebThread ui_thread_; | 71 web::TestWebThread ui_thread_; |
| 72 web::TestWebThread io_thread_; | 72 web::TestWebThread io_thread_; |
| 73 IOSChromeScopedTestingLocalState local_state_; | 73 IOSChromeScopedTestingLocalState local_state_; |
| 74 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | 74 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
| 75 FakeWebStateListDelegate webStateListDelegate_; | 75 FakeWebStateListDelegate webStateListDelegate_; |
| 76 std::unique_ptr<WebStateList> webStateList_; | 76 std::unique_ptr<WebStateList> webStateList_; |
| 77 OCMockObject* mockUrlLoader_; | 77 OCMockObject* mockUrlLoader_; |
| 78 GoogleLandingMediator* mediator_; | 78 GoogleLandingMediator* mediator_; |
| 79 GoogleLandingController* controller_; | 79 GoogleLandingViewController* controller_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 TEST_F(GoogleLandingControllerTest, TestConstructorDestructor) { | 82 TEST_F(GoogleLandingViewControllerTest, TestConstructorDestructor) { |
| 83 EXPECT_TRUE(controller_); | 83 EXPECT_TRUE(controller_); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // anonymous namespace | 86 } // anonymous namespace |
| OLD | NEW |