| 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/mac/scoped_nsobject.h" | |
| 8 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 10 #include "components/search_engines/template_url_service.h" | 9 #include "components/search_engines/template_url_service.h" |
| 11 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 12 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 13 #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" |
| 14 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" | 13 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" |
| 15 #include "ios/chrome/test/block_cleanup_test.h" | 14 #include "ios/chrome/test/block_cleanup_test.h" |
| 16 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" | 15 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" |
| 17 #include "ios/web/public/test/test_web_thread.h" | 16 #include "ios/web/public/test/test_web_thread.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "testing/gtest_mac.h" | 18 #include "testing/gtest_mac.h" |
| 20 #import "third_party/ocmock/OCMock/OCMock.h" | 19 #import "third_party/ocmock/OCMock/OCMock.h" |
| 21 | 20 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." |
| 23 #endif |
| 24 |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| 24 class GoogleLandingControllerTest : public BlockCleanupTest { | 27 class GoogleLandingControllerTest : public BlockCleanupTest { |
| 25 public: | 28 public: |
| 26 GoogleLandingControllerTest() | 29 GoogleLandingControllerTest() |
| 27 : ui_thread_(web::WebThread::UI, &message_loop_), | 30 : ui_thread_(web::WebThread::UI, &message_loop_), |
| 28 io_thread_(web::WebThread::IO, &message_loop_) {} | 31 io_thread_(web::WebThread::IO, &message_loop_) {} |
| 29 | 32 |
| 30 protected: | 33 protected: |
| 31 void SetUp() override { | 34 void SetUp() override { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 chrome_browser_state_ = test_cbs_builder.Build(); | 45 chrome_browser_state_ = test_cbs_builder.Build(); |
| 43 BlockCleanupTest::SetUp(); | 46 BlockCleanupTest::SetUp(); |
| 44 | 47 |
| 45 // Set up tab restore service. | 48 // Set up tab restore service. |
| 46 TemplateURLService* template_url_service = | 49 TemplateURLService* template_url_service = |
| 47 ios::TemplateURLServiceFactory::GetForBrowserState( | 50 ios::TemplateURLServiceFactory::GetForBrowserState( |
| 48 chrome_browser_state_.get()); | 51 chrome_browser_state_.get()); |
| 49 template_url_service->Load(); | 52 template_url_service->Load(); |
| 50 | 53 |
| 51 // Set up stub UrlLoader. | 54 // Set up stub UrlLoader. |
| 52 mockUrlLoader_.reset( | 55 mockUrlLoader_ = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; |
| 53 [[OCMockObject mockForProtocol:@protocol(UrlLoader)] retain]); | 56 controller_ = [[GoogleLandingController alloc] |
| 54 controller_.reset([[GoogleLandingController alloc] | 57 initWithLoader:(id<UrlLoader>)mockUrlLoader_ |
| 55 initWithLoader:(id<UrlLoader>)mockUrlLoader_.get() | |
| 56 browserState:chrome_browser_state_.get() | 58 browserState:chrome_browser_state_.get() |
| 57 focuser:nil | 59 focuser:nil |
| 58 webToolbarDelegate:nil | 60 webToolbarDelegate:nil |
| 59 tabModel:nil]); | 61 tabModel:nil]; |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 base::MessageLoopForUI message_loop_; | 64 base::MessageLoopForUI message_loop_; |
| 63 web::TestWebThread ui_thread_; | 65 web::TestWebThread ui_thread_; |
| 64 web::TestWebThread io_thread_; | 66 web::TestWebThread io_thread_; |
| 65 IOSChromeScopedTestingLocalState local_state_; | 67 IOSChromeScopedTestingLocalState local_state_; |
| 66 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | 68 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
| 67 base::scoped_nsobject<OCMockObject> mockUrlLoader_; | 69 OCMockObject* mockUrlLoader_; |
| 68 base::scoped_nsobject<GoogleLandingController> controller_; | 70 GoogleLandingController* controller_; |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 TEST_F(GoogleLandingControllerTest, TestConstructorDestructor) { | 73 TEST_F(GoogleLandingControllerTest, TestConstructorDestructor) { |
| 72 EXPECT_TRUE(controller_.get()); | 74 EXPECT_TRUE(controller_); |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // anonymous namespace | 77 } // anonymous namespace |
| OLD | NEW |