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 "chrome/browser/ui/search/instant_page.h" | 5 #include "chrome/browser/ui/search/instant_page.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/ui/search/search_tab_helper.h" | 12 #include "chrome/browser/ui/search/search_tab_helper.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
17 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "content/public/test/mock_render_process_host.h" | 20 #include "content/public/test/mock_render_process_host.h" |
20 #include "ipc/ipc_test_sink.h" | 21 #include "ipc/ipc_test_sink.h" |
(...skipping 29 matching lines...) Expand all Loading... |
50 } // namespace | 51 } // namespace |
51 | 52 |
52 class InstantPageTest : public ChromeRenderViewHostTestHarness { | 53 class InstantPageTest : public ChromeRenderViewHostTestHarness { |
53 public: | 54 public: |
54 void SetUp() override; | 55 void SetUp() override; |
55 | 56 |
56 bool MessageWasSent(uint32_t id) { | 57 bool MessageWasSent(uint32_t id) { |
57 return process()->sink().GetFirstMessageMatching(id) != NULL; | 58 return process()->sink().GetFirstMessageMatching(id) != NULL; |
58 } | 59 } |
59 | 60 |
60 scoped_ptr<InstantPage> page; | 61 std::unique_ptr<InstantPage> page; |
61 FakePageDelegate delegate; | 62 FakePageDelegate delegate; |
62 }; | 63 }; |
63 | 64 |
64 void InstantPageTest::SetUp() { | 65 void InstantPageTest::SetUp() { |
65 ChromeRenderViewHostTestHarness::SetUp(); | 66 ChromeRenderViewHostTestHarness::SetUp(); |
66 SearchTabHelper::CreateForWebContents(web_contents()); | 67 SearchTabHelper::CreateForWebContents(web_contents()); |
67 } | 68 } |
68 | 69 |
69 TEST_F(InstantPageTest, IsLocal) { | 70 TEST_F(InstantPageTest, IsLocal) { |
70 page.reset(new InstantPage(&delegate, "", NULL)); | 71 page.reset(new InstantPage(&delegate, "", NULL)); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 .Times(1); | 148 .Times(1); |
148 | 149 |
149 // Assume the page supports instant. Invoke the message reply handler to make | 150 // Assume the page supports instant. Invoke the message reply handler to make |
150 // sure the InstantPage is notified about the instant support state. | 151 // sure the InstantPage is notified about the instant support state. |
151 const content::NavigationEntry* entry = | 152 const content::NavigationEntry* entry = |
152 web_contents()->GetController().GetLastCommittedEntry(); | 153 web_contents()->GetController().GetLastCommittedEntry(); |
153 EXPECT_TRUE(entry); | 154 EXPECT_TRUE(entry); |
154 SearchTabHelper::FromWebContents(web_contents())->InstantSupportChanged(true); | 155 SearchTabHelper::FromWebContents(web_contents())->InstantSupportChanged(true); |
155 EXPECT_TRUE(page->supports_instant()); | 156 EXPECT_TRUE(page->supports_instant()); |
156 } | 157 } |
OLD | NEW |