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