| 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/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/signin/fake_signin_manager.h" | 10 #include "chrome/browser/signin/fake_signin_manager.h" |
| 11 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
| 12 #include "chrome/browser/ui/search/search_ipc_router.h" | 12 #include "chrome/browser/ui/search/search_ipc_router.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/ntp_logging_events.h" | 14 #include "chrome/common/ntp_logging_events.h" |
| 15 #include "chrome/common/omnibox_focus_state.h" | 15 #include "chrome/common/omnibox_focus_state.h" |
| 16 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 20 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
| 21 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
| 24 #include "grit/generated_resources.h" |
| 24 #include "ipc/ipc_message.h" | 25 #include "ipc/ipc_message.h" |
| 25 #include "ipc/ipc_test_sink.h" | 26 #include "ipc/ipc_test_sink.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 class MockSearchIPCRouterDelegate : public SearchIPCRouter::Delegate { | 34 class MockSearchIPCRouterDelegate : public SearchIPCRouter::Delegate { |
| 33 public: | 35 public: |
| 34 virtual ~MockSearchIPCRouterDelegate() {} | 36 virtual ~MockSearchIPCRouterDelegate() {} |
| 35 | 37 |
| 36 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); | 38 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); |
| 37 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search)); | 39 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search)); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 200 |
| 199 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( | 201 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( |
| 200 ChromeViewMsg_ChromeIdentityCheckResult::ID); | 202 ChromeViewMsg_ChromeIdentityCheckResult::ID); |
| 201 ASSERT_TRUE(message != NULL); | 203 ASSERT_TRUE(message != NULL); |
| 202 | 204 |
| 203 ChromeViewMsg_ChromeIdentityCheckResult::Param params; | 205 ChromeViewMsg_ChromeIdentityCheckResult::Param params; |
| 204 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, ¶ms); | 206 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, ¶ms); |
| 205 EXPECT_EQ(test_identity, params.a); | 207 EXPECT_EQ(test_identity, params.a); |
| 206 ASSERT_FALSE(params.b); | 208 ASSERT_FALSE(params.b); |
| 207 } | 209 } |
| 210 |
| 211 class TabTitleObserver : public content::WebContentsObserver { |
| 212 public: |
| 213 explicit TabTitleObserver(content::WebContents* contents) |
| 214 : WebContentsObserver(contents) {} |
| 215 |
| 216 string16 title_on_start() { return title_on_start_; } |
| 217 string16 title_on_commit() { return title_on_commit_; } |
| 218 |
| 219 private: |
| 220 virtual void DidStartProvisionalLoadForFrame( |
| 221 int64 /* frame_id */, |
| 222 int64 /* parent_frame_id */, |
| 223 bool /* is_main_frame */, |
| 224 const GURL& /* validated_url */, |
| 225 bool /* is_error_page */, |
| 226 bool /* is_iframe_srcdoc */, |
| 227 content::RenderViewHost* /* render_view_host */) OVERRIDE { |
| 228 title_on_start_ = web_contents()->GetTitle(); |
| 229 } |
| 230 |
| 231 virtual void DidNavigateMainFrame( |
| 232 const content::LoadCommittedDetails& /* details */, |
| 233 const content::FrameNavigateParams& /* params */) OVERRIDE { |
| 234 title_on_commit_ = web_contents()->GetTitle(); |
| 235 } |
| 236 |
| 237 string16 title_on_start_; |
| 238 string16 title_on_commit_; |
| 239 }; |
| 240 |
| 241 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { |
| 242 TabTitleObserver title_observer(web_contents()); |
| 243 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); |
| 244 const string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
| 245 EXPECT_EQ(title, title_observer.title_on_start()); |
| 246 EXPECT_EQ(title, title_observer.title_on_commit()); |
| 247 EXPECT_EQ(title, web_contents()->GetTitle()); |
| 248 } |
| OLD | NEW |