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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { | 46 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { |
47 public: | 47 public: |
48 ConstrainedWebDialogBrowserTest() {} | 48 ConstrainedWebDialogBrowserTest() {} |
49 | 49 |
50 protected: | 50 protected: |
51 size_t GetConstrainedWindowCount(WebContents* web_contents) const { | 51 size_t GetConstrainedWindowCount(WebContents* web_contents) const { |
52 ConstrainedWindowTabHelper* constrained_window_tab_helper = | 52 ConstrainedWindowTabHelper* constrained_window_tab_helper = |
53 ConstrainedWindowTabHelper::FromWebContents(web_contents); | 53 ConstrainedWindowTabHelper::FromWebContents(web_contents); |
54 return constrained_window_tab_helper->constrained_window_count(); | 54 return constrained_window_tab_helper->dialog_count(); |
55 } | 55 } |
56 }; | 56 }; |
57 | 57 |
58 // Tests that opening/closing the constrained window won't crash it. | 58 // Tests that opening/closing the constrained window won't crash it. |
59 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { | 59 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { |
60 // The delegate deletes itself. | 60 // The delegate deletes itself. |
61 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( | 61 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( |
62 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); | 62 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); |
63 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 63 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
64 ASSERT_TRUE(web_contents); | 64 ASSERT_TRUE(web_contents); |
(...skipping 29 matching lines...) Expand all Loading... |
94 | 94 |
95 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); | 95 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); |
96 dialog_delegate->ReleaseWebContentsOnDialogClose(); | 96 dialog_delegate->ReleaseWebContentsOnDialogClose(); |
97 dialog_delegate->OnDialogCloseFromWebUI(); | 97 dialog_delegate->OnDialogCloseFromWebUI(); |
98 | 98 |
99 ASSERT_FALSE(observer.contents_destroyed()); | 99 ASSERT_FALSE(observer.contents_destroyed()); |
100 EXPECT_EQ(0U, GetConstrainedWindowCount(web_contents)); | 100 EXPECT_EQ(0U, GetConstrainedWindowCount(web_contents)); |
101 new_tab.reset(); | 101 new_tab.reset(); |
102 EXPECT_TRUE(observer.contents_destroyed()); | 102 EXPECT_TRUE(observer.contents_destroyed()); |
103 } | 103 } |
OLD | NEW |