OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/web_dialogs/web_dialog_web_contents_delegate.h" | 5 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 test_web_contents_delegate_->LoadingStateChanged(NULL, true); | 72 test_web_contents_delegate_->LoadingStateChanged(NULL, true); |
73 test_web_contents_delegate_->CloseContents(NULL); | 73 test_web_contents_delegate_->CloseContents(NULL); |
74 test_web_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); | 74 test_web_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); |
75 test_web_contents_delegate_->MoveContents(NULL, gfx::Rect()); | 75 test_web_contents_delegate_->MoveContents(NULL, gfx::Rect()); |
76 EXPECT_EQ(0, browser()->tab_strip_model()->count()); | 76 EXPECT_EQ(0, browser()->tab_strip_model()->count()); |
77 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 77 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
78 } | 78 } |
79 | 79 |
80 TEST_F(WebDialogWebContentsDelegateTest, OpenURLFromTabTest) { | 80 TEST_F(WebDialogWebContentsDelegateTest, OpenURLFromTabTest) { |
81 test_web_contents_delegate_->OpenURLFromTab( | 81 test_web_contents_delegate_->OpenURLFromTab( |
82 NULL, OpenURLParams(GURL(content::kAboutBlankURL), Referrer(), | 82 NULL, |
83 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); | 83 OpenURLParams(GURL(url::kAboutBlankURL), |
| 84 Referrer(), |
| 85 NEW_FOREGROUND_TAB, |
| 86 content::PAGE_TRANSITION_LINK, |
| 87 false)); |
84 // This should create a new foreground tab in the existing browser. | 88 // This should create a new foreground tab in the existing browser. |
85 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 89 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
86 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 90 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
87 } | 91 } |
88 | 92 |
89 TEST_F(WebDialogWebContentsDelegateTest, AddNewContentsForegroundTabTest) { | 93 TEST_F(WebDialogWebContentsDelegateTest, AddNewContentsForegroundTabTest) { |
90 WebContents* contents = | 94 WebContents* contents = |
91 WebContentsTester::CreateTestWebContents(profile(), NULL); | 95 WebContentsTester::CreateTestWebContents(profile(), NULL); |
92 test_web_contents_delegate_->AddNewContents( | 96 test_web_contents_delegate_->AddNewContents( |
93 NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false, NULL); | 97 NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false, NULL); |
94 // This should create a new foreground tab in the existing browser. | 98 // This should create a new foreground tab in the existing browser. |
95 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 99 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
96 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 100 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
97 } | 101 } |
98 | 102 |
99 TEST_F(WebDialogWebContentsDelegateTest, DetachTest) { | 103 TEST_F(WebDialogWebContentsDelegateTest, DetachTest) { |
100 EXPECT_EQ(profile(), test_web_contents_delegate_->browser_context()); | 104 EXPECT_EQ(profile(), test_web_contents_delegate_->browser_context()); |
101 test_web_contents_delegate_->Detach(); | 105 test_web_contents_delegate_->Detach(); |
102 EXPECT_EQ(NULL, test_web_contents_delegate_->browser_context()); | 106 EXPECT_EQ(NULL, test_web_contents_delegate_->browser_context()); |
103 // Now, none of the following calls should do anything. | 107 // Now, none of the following calls should do anything. |
104 test_web_contents_delegate_->OpenURLFromTab( | 108 test_web_contents_delegate_->OpenURLFromTab( |
105 NULL, OpenURLParams(GURL(content::kAboutBlankURL), Referrer(), | 109 NULL, |
106 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); | 110 OpenURLParams(GURL(url::kAboutBlankURL), |
| 111 Referrer(), |
| 112 NEW_FOREGROUND_TAB, |
| 113 content::PAGE_TRANSITION_LINK, |
| 114 false)); |
107 test_web_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, | 115 test_web_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, |
108 gfx::Rect(), false, NULL); | 116 gfx::Rect(), false, NULL); |
109 EXPECT_EQ(0, browser()->tab_strip_model()->count()); | 117 EXPECT_EQ(0, browser()->tab_strip_model()->count()); |
110 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 118 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
111 } | 119 } |
112 | 120 |
113 } // namespace | 121 } // namespace |
OLD | NEW |