OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.h" |
6 #include "chrome/test/in_process_browser_test.h" | 6 #include "chrome/test/in_process_browser_test.h" |
7 #include "net/base/host_resolver_unittest.h" | 7 #include "net/base/mock_host_resolver.h" |
8 | 8 |
9 class BrowserTest : public InProcessBrowserTest { | 9 class BrowserTest : public InProcessBrowserTest { |
10 public: | 10 public: |
11 BrowserTest() { | 11 BrowserTest() { |
12 host_mapper_ = new net::RuleBasedHostMapper(); | 12 host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL); |
13 // Avoid making external DNS lookups. In this test we don't need this | 13 // Avoid making external DNS lookups. In this test we don't need this |
14 // to succeed. | 14 // to succeed. |
15 host_mapper_->AddSimulatedFailure("*.google.com"); | 15 host_resolver_proc_->AddSimulatedFailure("*.google.com"); |
16 scoped_host_mapper_.Init(host_mapper_.get()); | 16 scoped_host_resolver_proc_.Init(host_resolver_proc_.get()); |
17 } | 17 } |
18 | 18 |
19 private: | 19 private: |
20 scoped_refptr<net::RuleBasedHostMapper> host_mapper_; | 20 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; |
21 net::ScopedHostMapper scoped_host_mapper_; | 21 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; |
22 }; | 22 }; |
23 | 23 |
24 /* | 24 /* |
25 // This tests that windows without tabstrips can't have new tabs opened in | 25 // This tests that windows without tabstrips can't have new tabs opened in |
26 // them. | 26 // them. |
27 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTabsInPopups) { | 27 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTabsInPopups) { |
28 Browser::RegisterAppPrefs(L"Test"); | 28 Browser::RegisterAppPrefs(L"Test"); |
29 | 29 |
30 // We start with a normal browser with one tab. | 30 // We start with a normal browser with one tab. |
31 EXPECT_EQ(1, browser()->tab_count()); | 31 EXPECT_EQ(1, browser()->tab_count()); |
32 | 32 |
33 // Open a popup browser with a single blank foreground tab. | 33 // Open a popup browser with a single blank foreground tab. |
34 Browser* popup_browser = browser()->CreateForPopup(browser()->profile()); | 34 Browser* popup_browser = browser()->CreateForPopup(browser()->profile()); |
35 popup_browser->AddBlankTab(true); | 35 popup_browser->AddBlankTab(true); |
36 EXPECT_EQ(1, popup_browser->tab_count()); | 36 EXPECT_EQ(1, popup_browser->tab_count()); |
37 | 37 |
38 // Now try opening another tab in the popup browser. | 38 // Now try opening another tab in the popup browser. |
39 popup_browser->AddTabWithURL(GURL("about:blank"), GURL(), | 39 popup_browser->AddTabWithURL(GURL("about:blank"), GURL(), |
40 PageTransition::TYPED, true, -1, NULL); | 40 PageTransition::TYPED, true, -1, NULL); |
41 | 41 |
42 // The popup should still only have one tab. | 42 // The popup should still only have one tab. |
43 EXPECT_EQ(1, popup_browser->tab_count()); | 43 EXPECT_EQ(1, popup_browser->tab_count()); |
44 | 44 |
45 // The normal browser should now have two. | 45 // The normal browser should now have two. |
46 EXPECT_EQ(2, browser()->tab_count()); | 46 EXPECT_EQ(2, browser()->tab_count()); |
47 | 47 |
48 // Open an app frame browser with a single blank foreground tab. | 48 // Open an app frame browser with a single blank foreground tab. |
49 Browser* app_browser = | 49 Browser* app_browser = |
50 browser()->CreateForApp(L"Test", browser()->profile(), false); | 50 browser()->CreateForApp(L"Test", browser()->profile(), false); |
51 app_browser->AddBlankTab(true); | 51 app_browser->AddBlankTab(true); |
52 EXPECT_EQ(1, app_browser->tab_count()); | 52 EXPECT_EQ(1, app_browser->tab_count()); |
53 | 53 |
54 // Now try opening another tab in the app browser. | 54 // Now try opening another tab in the app browser. |
55 app_browser->AddTabWithURL(GURL("about:blank"), GURL(), | 55 app_browser->AddTabWithURL(GURL("about:blank"), GURL(), |
56 PageTransition::TYPED, true, -1, NULL); | 56 PageTransition::TYPED, true, -1, NULL); |
57 | 57 |
58 // The popup should still only have one tab. | 58 // The popup should still only have one tab. |
59 EXPECT_EQ(1, app_browser->tab_count()); | 59 EXPECT_EQ(1, app_browser->tab_count()); |
60 | 60 |
61 // The normal browser should now have three. | 61 // The normal browser should now have three. |
62 EXPECT_EQ(3, browser()->tab_count()); | 62 EXPECT_EQ(3, browser()->tab_count()); |
63 | 63 |
64 // Open an app frame popup browser with a single blank foreground tab. | 64 // Open an app frame popup browser with a single blank foreground tab. |
65 Browser* app_popup_browser = | 65 Browser* app_popup_browser = |
66 browser()->CreateForApp(L"Test", browser()->profile(), false); | 66 browser()->CreateForApp(L"Test", browser()->profile(), false); |
67 app_popup_browser->AddBlankTab(true); | 67 app_popup_browser->AddBlankTab(true); |
68 EXPECT_EQ(1, app_popup_browser->tab_count()); | 68 EXPECT_EQ(1, app_popup_browser->tab_count()); |
69 | 69 |
70 // Now try opening another tab in the app popup browser. | 70 // Now try opening another tab in the app popup browser. |
71 app_popup_browser->AddTabWithURL(GURL("about:blank"), GURL(), | 71 app_popup_browser->AddTabWithURL(GURL("about:blank"), GURL(), |
72 PageTransition::TYPED, true, -1, NULL); | 72 PageTransition::TYPED, true, -1, NULL); |
73 | 73 |
74 // The popup should still only have one tab. | 74 // The popup should still only have one tab. |
75 EXPECT_EQ(1, app_popup_browser->tab_count()); | 75 EXPECT_EQ(1, app_popup_browser->tab_count()); |
76 | 76 |
77 // The normal browser should now have four. | 77 // The normal browser should now have four. |
78 EXPECT_EQ(4, browser()->tab_count()); | 78 EXPECT_EQ(4, browser()->tab_count()); |
79 | 79 |
80 // Close the additional browsers. | 80 // Close the additional browsers. |
81 popup_browser->CloseAllTabs(); | 81 popup_browser->CloseAllTabs(); |
82 app_browser->CloseAllTabs(); | 82 app_browser->CloseAllTabs(); |
83 app_popup_browser->CloseAllTabs(); | 83 app_popup_browser->CloseAllTabs(); |
84 } | 84 } |
85 */ | 85 */ |
OLD | NEW |