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/mac/scoped_nsobject.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 10 #include "components/search_engines/template_url_service.h" |
| 11 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 12 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 13 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" |
| 14 #import "ios/chrome/browser/ui/ntp/google_landing_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 namespace { |
| 23 |
| 24 class GoogleLandingControllerTest : public BlockCleanupTest { |
| 25 public: |
| 26 GoogleLandingControllerTest() |
| 27 : ui_thread_(web::WebThread::UI, &message_loop_), |
| 28 io_thread_(web::WebThread::IO, &message_loop_) {} |
| 29 |
| 30 protected: |
| 31 void SetUp() override { |
| 32 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 33 |
| 34 TestChromeBrowserState::Builder test_cbs_builder; |
| 35 test_cbs_builder.AddTestingFactory( |
| 36 IOSChromeTabRestoreServiceFactory::GetInstance(), |
| 37 IOSChromeTabRestoreServiceFactory::GetDefaultFactory()); |
| 38 test_cbs_builder.AddTestingFactory( |
| 39 ios::TemplateURLServiceFactory::GetInstance(), |
| 40 ios::TemplateURLServiceFactory::GetDefaultFactory()); |
| 41 |
| 42 chrome_browser_state_ = test_cbs_builder.Build(); |
| 43 BlockCleanupTest::SetUp(); |
| 44 |
| 45 // Set up tab restore service. |
| 46 TemplateURLService* template_url_service = |
| 47 ios::TemplateURLServiceFactory::GetForBrowserState( |
| 48 chrome_browser_state_.get()); |
| 49 template_url_service->Load(); |
| 50 |
| 51 // Set up stub UrlLoader. |
| 52 mockUrlLoader_.reset( |
| 53 [[OCMockObject mockForProtocol:@protocol(UrlLoader)] retain]); |
| 54 controller_.reset([[GoogleLandingController alloc] |
| 55 initWithLoader:(id<UrlLoader>)mockUrlLoader_.get() |
| 56 browserState:chrome_browser_state_.get() |
| 57 focuser:nil |
| 58 webToolbarDelegate:nil |
| 59 tabModel:nil]); |
| 60 }; |
| 61 |
| 62 base::MessageLoopForUI message_loop_; |
| 63 web::TestWebThread ui_thread_; |
| 64 web::TestWebThread io_thread_; |
| 65 IOSChromeScopedTestingLocalState local_state_; |
| 66 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
| 67 base::scoped_nsobject<OCMockObject> mockUrlLoader_; |
| 68 base::scoped_nsobject<GoogleLandingController> controller_; |
| 69 }; |
| 70 |
| 71 TEST_F(GoogleLandingControllerTest, TestConstructorDestructor) { |
| 72 EXPECT_TRUE(controller_.get()); |
| 73 } |
| 74 |
| 75 } // anonymous namespace |
OLD | NEW |