| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/search_engines/template_url_service_factory.h" | 5 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 6 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 6 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 7 #include "chrome/common/url_constants.h" | 7 #include "chrome/common/url_constants.h" |
| 8 #include "chrome/test/base/browser_with_test_window_test.h" | 8 #include "chrome/test/base/browser_with_test_window_test.h" |
| 9 #include "components/search_engines/search_terms_data.h" | 9 #include "components/search_engines/search_terms_data.h" |
| 10 #include "components/search_engines/template_url_service.h" | 10 #include "components/search_engines/template_url_service.h" |
| 11 #include "components/search_engines/template_url_service_client.h" | 11 #include "components/search_engines/template_url_service_client.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 typedef BrowserWithTestWindowTest BookmarkTest; | 15 typedef BrowserWithTestWindowTest BookmarkTest; |
| 16 | 16 |
| 17 // Verify that the detached bookmark bar is visible on the new tab page. | 17 // Verify that the detached bookmark bar is visible on the new tab page. |
| 18 TEST_F(BookmarkTest, DetachedBookmarkBarOnNTP) { | 18 TEST_F(BookmarkTest, DetachedBookmarkBarOnNTP) { |
| 19 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); | 19 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 20 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | 20 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Verify that the detached bookmark bar is hidden on custom NTP pages. | 23 // Verify that the detached bookmark bar is hidden on custom NTP pages. |
| 24 TEST_F(BookmarkTest, DetachedBookmarkBarOnCustomNTP) { | 24 TEST_F(BookmarkTest, DetachedBookmarkBarOnCustomNTP) { |
| 25 // Create a empty commited web contents. | 25 // Create a empty commited web contents. |
| 26 content::WebContents* web_contents = content::WebContents::Create( | 26 content::WebContents* web_contents = content::WebContents::Create( |
| 27 content::WebContents::CreateParams(browser()->profile())); | 27 content::WebContents::CreateParams(browser()->profile())); |
| 28 web_contents->GetController().LoadURL(GURL(url::kAboutBlankURL), | 28 web_contents->GetController().LoadURL(GURL(url::kAboutBlankURL), |
| 29 content::Referrer(), | 29 content::Referrer(), |
| 30 content::PAGE_TRANSITION_LINK, | 30 ui::PAGE_TRANSITION_LINK, |
| 31 std::string()); | 31 std::string()); |
| 32 | 32 |
| 33 // Give it a NTP virtual URL. | 33 // Give it a NTP virtual URL. |
| 34 content::NavigationController* controller = &web_contents->GetController(); | 34 content::NavigationController* controller = &web_contents->GetController(); |
| 35 content::NavigationEntry* entry = controller->GetVisibleEntry(); | 35 content::NavigationEntry* entry = controller->GetVisibleEntry(); |
| 36 entry->SetVirtualURL(GURL(chrome::kChromeUINewTabURL)); | 36 entry->SetVirtualURL(GURL(chrome::kChromeUINewTabURL)); |
| 37 | 37 |
| 38 // Verify that the detached bookmark bar is hidden. | 38 // Verify that the detached bookmark bar is hidden. |
| 39 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 39 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 40 browser()->tab_strip_model()->AppendWebContents(web_contents, true); | 40 browser()->tab_strip_model()->AppendWebContents(web_contents, true); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(BookmarkInstantExtendedTest); | 68 DISALLOW_COPY_AND_ASSIGN(BookmarkInstantExtendedTest); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // Verify that in instant extended mode the detached bookmark bar is visible on | 71 // Verify that in instant extended mode the detached bookmark bar is visible on |
| 72 // the new tab page. | 72 // the new tab page. |
| 73 TEST_F(BookmarkInstantExtendedTest, DetachedBookmarkBarOnNTP) { | 73 TEST_F(BookmarkInstantExtendedTest, DetachedBookmarkBarOnNTP) { |
| 74 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); | 74 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 75 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | 75 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); |
| 76 } | 76 } |
| OLD | NEW |