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