| 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" | 13 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" |
| 14 #import "ios/chrome/browser/ui/ntp/google_landing_mediator.h" | 14 #import "ios/chrome/browser/ui/ntp/google_landing_mediator.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" | |
| 17 #include "ios/chrome/test/block_cleanup_test.h" | 15 #include "ios/chrome/test/block_cleanup_test.h" |
| 18 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" | 16 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" |
| 19 #include "ios/web/public/test/test_web_thread.h" | 17 #include "ios/web/public/test/test_web_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "testing/gtest_mac.h" | 19 #include "testing/gtest_mac.h" |
| 22 #import "third_party/ocmock/OCMock/OCMock.h" | 20 #import "third_party/ocmock/OCMock/OCMock.h" |
| 23 | 21 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) | 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." | 23 #error "This file requires ARC support." |
| 26 #endif | 24 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 50 | 48 |
| 51 // Set up tab restore service. | 49 // Set up tab restore service. |
| 52 TemplateURLService* template_url_service = | 50 TemplateURLService* template_url_service = |
| 53 ios::TemplateURLServiceFactory::GetForBrowserState( | 51 ios::TemplateURLServiceFactory::GetForBrowserState( |
| 54 chrome_browser_state_.get()); | 52 chrome_browser_state_.get()); |
| 55 template_url_service->Load(); | 53 template_url_service->Load(); |
| 56 | 54 |
| 57 // Set up stub UrlLoader. | 55 // Set up stub UrlLoader. |
| 58 mockUrlLoader_ = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; | 56 mockUrlLoader_ = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; |
| 59 controller_ = [[GoogleLandingController alloc] init]; | 57 controller_ = [[GoogleLandingController alloc] init]; |
| 60 webStateList_ = base::MakeUnique<WebStateList>(&webStateListDelegate_); | |
| 61 mediator_ = [[GoogleLandingMediator alloc] | 58 mediator_ = [[GoogleLandingMediator alloc] |
| 62 initWithConsumer:controller_ | 59 initWithConsumer:controller_ |
| 63 browserState:chrome_browser_state_.get() | 60 browserState:chrome_browser_state_.get() |
| 64 loader:(id<UrlLoader>)mockUrlLoader_ | 61 loader:(id<UrlLoader>)mockUrlLoader_ |
| 65 focuser:nil | 62 focuser:nil |
| 66 webToolbarDelegate:nil | 63 webToolbarDelegate:nil |
| 67 webStateList:webStateList_.get()]; | 64 tabModel:nil]; |
| 68 }; | 65 }; |
| 69 | 66 |
| 70 base::MessageLoopForUI message_loop_; | 67 base::MessageLoopForUI message_loop_; |
| 71 web::TestWebThread ui_thread_; | 68 web::TestWebThread ui_thread_; |
| 72 web::TestWebThread io_thread_; | 69 web::TestWebThread io_thread_; |
| 73 IOSChromeScopedTestingLocalState local_state_; | 70 IOSChromeScopedTestingLocalState local_state_; |
| 74 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | 71 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
| 75 FakeWebStateListDelegate webStateListDelegate_; | |
| 76 std::unique_ptr<WebStateList> webStateList_; | |
| 77 OCMockObject* mockUrlLoader_; | 72 OCMockObject* mockUrlLoader_; |
| 78 GoogleLandingMediator* mediator_; | 73 GoogleLandingMediator* mediator_; |
| 79 GoogleLandingController* controller_; | 74 GoogleLandingController* controller_; |
| 80 }; | 75 }; |
| 81 | 76 |
| 82 TEST_F(GoogleLandingControllerTest, TestConstructorDestructor) { | 77 TEST_F(GoogleLandingControllerTest, TestConstructorDestructor) { |
| 83 EXPECT_TRUE(controller_); | 78 EXPECT_TRUE(controller_); |
| 84 } | 79 } |
| 85 | 80 |
| 86 } // anonymous namespace | 81 } // anonymous namespace |
| OLD | NEW |