| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( | 314 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( |
| 315 ChromeViewMsg_HistorySyncCheckResult::ID); | 315 ChromeViewMsg_HistorySyncCheckResult::ID); |
| 316 ASSERT_TRUE(message != NULL); | 316 ASSERT_TRUE(message != NULL); |
| 317 | 317 |
| 318 ChromeViewMsg_HistorySyncCheckResult::Param params; | 318 ChromeViewMsg_HistorySyncCheckResult::Param params; |
| 319 ChromeViewMsg_HistorySyncCheckResult::Read(message, ¶ms); | 319 ChromeViewMsg_HistorySyncCheckResult::Read(message, ¶ms); |
| 320 ASSERT_FALSE(std::get<0>(params)); | 320 ASSERT_FALSE(std::get<0>(params)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TEST_F(SearchTabHelperTest, OnMostVisitedItemsChangedFromServer) { | |
| 324 InstantMostVisitedItem item; | |
| 325 item.is_server_side_suggestion = true; | |
| 326 std::vector<InstantMostVisitedItem> items; | |
| 327 items.push_back(item); | |
| 328 | |
| 329 SearchTabHelper* search_tab_helper = | |
| 330 SearchTabHelper::FromWebContents(web_contents()); | |
| 331 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); | |
| 332 | |
| 333 auto logger = NTPUserDataLogger::GetOrCreateFromWebContents(web_contents()); | |
| 334 ASSERT_FALSE(logger->has_server_side_suggestions_); | |
| 335 ASSERT_FALSE(logger->has_client_side_suggestions_); | |
| 336 | |
| 337 search_tab_helper->MostVisitedItemsChanged(items); | |
| 338 | |
| 339 ASSERT_TRUE(logger->has_server_side_suggestions_); | |
| 340 ASSERT_FALSE(logger->has_client_side_suggestions_); | |
| 341 } | |
| 342 | |
| 343 TEST_F(SearchTabHelperTest, OnMostVisitedItemsChangedFromClient) { | |
| 344 InstantMostVisitedItem item; | |
| 345 item.is_server_side_suggestion = false; | |
| 346 std::vector<InstantMostVisitedItem> items; | |
| 347 items.push_back(item); | |
| 348 | |
| 349 SearchTabHelper* search_tab_helper = | |
| 350 SearchTabHelper::FromWebContents(web_contents()); | |
| 351 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); | |
| 352 | |
| 353 auto logger = NTPUserDataLogger::GetOrCreateFromWebContents(web_contents()); | |
| 354 ASSERT_FALSE(logger->has_server_side_suggestions_); | |
| 355 ASSERT_FALSE(logger->has_client_side_suggestions_); | |
| 356 | |
| 357 search_tab_helper->MostVisitedItemsChanged(items); | |
| 358 | |
| 359 ASSERT_FALSE(logger->has_server_side_suggestions_); | |
| 360 ASSERT_TRUE(logger->has_client_side_suggestions_); | |
| 361 } | |
| 362 | |
| 363 class TabTitleObserver : public content::WebContentsObserver { | 323 class TabTitleObserver : public content::WebContentsObserver { |
| 364 public: | 324 public: |
| 365 explicit TabTitleObserver(content::WebContents* contents) | 325 explicit TabTitleObserver(content::WebContents* contents) |
| 366 : WebContentsObserver(contents) {} | 326 : WebContentsObserver(contents) {} |
| 367 | 327 |
| 368 base::string16 title_on_start() { return title_on_start_; } | 328 base::string16 title_on_start() { return title_on_start_; } |
| 369 base::string16 title_on_commit() { return title_on_commit_; } | 329 base::string16 title_on_commit() { return title_on_commit_; } |
| 370 | 330 |
| 371 private: | 331 private: |
| 372 void DidStartProvisionalLoadForFrame( | 332 void DidStartProvisionalLoadForFrame( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 } | 413 } |
| 454 | 414 |
| 455 TEST_F(SearchTabHelperPrerenderTest, | 415 TEST_F(SearchTabHelperPrerenderTest, |
| 456 OnTabActivatedNoPrerenderIfOmniboxBlurred) { | 416 OnTabActivatedNoPrerenderIfOmniboxBlurred) { |
| 457 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; | 417 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; |
| 458 SearchTabHelper* search_tab_helper = | 418 SearchTabHelper* search_tab_helper = |
| 459 SearchTabHelper::FromWebContents(web_contents()); | 419 SearchTabHelper::FromWebContents(web_contents()); |
| 460 search_tab_helper->OnTabActivated(); | 420 search_tab_helper->OnTabActivated(); |
| 461 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); | 421 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); |
| 462 } | 422 } |
| OLD | NEW |