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