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/search.h" | |
6 #include "chrome/browser/search_engines/template_url_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
7 #include "chrome/browser/search_engines/template_url_service_factory.h" | 6 #include "chrome/browser/search_engines/template_url_service_factory.h" |
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
9 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/browser_with_test_window_test.h" | 9 #include "chrome/test/base/browser_with_test_window_test.h" |
11 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
12 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
13 | 12 |
14 typedef BrowserWithTestWindowTest BookmarkTest; | 13 typedef BrowserWithTestWindowTest BookmarkTest; |
15 | 14 |
(...skipping 19 matching lines...) Expand all Loading... |
35 | 34 |
36 // Verify that the detached bookmark bar is hidden. | 35 // Verify that the detached bookmark bar is hidden. |
37 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 36 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
38 browser()->tab_strip_model()->AppendWebContents(web_contents, true); | 37 browser()->tab_strip_model()->AppendWebContents(web_contents, true); |
39 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 38 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
40 } | 39 } |
41 | 40 |
42 class BookmarkInstantExtendedTest : public BrowserWithTestWindowTest { | 41 class BookmarkInstantExtendedTest : public BrowserWithTestWindowTest { |
43 public: | 42 public: |
44 BookmarkInstantExtendedTest() { | 43 BookmarkInstantExtendedTest() { |
45 chrome::EnableInstantExtendedAPIForTesting(); | |
46 } | 44 } |
47 | 45 |
48 protected: | 46 protected: |
49 virtual TestingProfile* CreateProfile() OVERRIDE { | 47 virtual TestingProfile* CreateProfile() OVERRIDE { |
50 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); | 48 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); |
51 // TemplateURLService is normally NULL during testing. Instant extended | 49 // TemplateURLService is normally NULL during testing. Instant extended |
52 // needs this service so set a custom factory function. | 50 // needs this service so set a custom factory function. |
53 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 51 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
54 profile, &BookmarkInstantExtendedTest::CreateTemplateURLService); | 52 profile, &BookmarkInstantExtendedTest::CreateTemplateURLService); |
55 return profile; | 53 return profile; |
56 } | 54 } |
57 | 55 |
58 private: | 56 private: |
59 static BrowserContextKeyedService* CreateTemplateURLService( | 57 static BrowserContextKeyedService* CreateTemplateURLService( |
60 content::BrowserContext* profile) { | 58 content::BrowserContext* profile) { |
61 return new TemplateURLService(static_cast<Profile*>(profile)); | 59 return new TemplateURLService(static_cast<Profile*>(profile)); |
62 } | 60 } |
63 | 61 |
64 DISALLOW_COPY_AND_ASSIGN(BookmarkInstantExtendedTest); | 62 DISALLOW_COPY_AND_ASSIGN(BookmarkInstantExtendedTest); |
65 }; | 63 }; |
66 | 64 |
67 // 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 |
68 // the new tab page. | 66 // the new tab page. |
69 TEST_F(BookmarkInstantExtendedTest, DetachedBookmarkBarOnNTP) { | 67 TEST_F(BookmarkInstantExtendedTest, DetachedBookmarkBarOnNTP) { |
70 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); | 68 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); |
71 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | 69 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); |
72 } | 70 } |
OLD | NEW |