| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 9 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Tests that opening/closing the constrained window won't crash it. | 54 // Tests that opening/closing the constrained window won't crash it. |
| 55 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { | 55 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { |
| 56 // The delegate deletes itself. | 56 // The delegate deletes itself. |
| 57 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( | 57 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( |
| 58 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); | 58 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); |
| 59 WebContents* web_contents = | 59 WebContents* web_contents = |
| 60 browser()->tab_strip_model()->GetActiveWebContents(); | 60 browser()->tab_strip_model()->GetActiveWebContents(); |
| 61 ASSERT_TRUE(web_contents); | 61 ASSERT_TRUE(web_contents); |
| 62 | 62 |
| 63 ConstrainedWebDialogDelegate* dialog_delegate = | 63 ConstrainedWebDialogDelegate* dialog_delegate = |
| 64 CreateConstrainedWebDialog(browser()->profile(), delegate, web_contents); | 64 ShowConstrainedWebDialog(browser()->profile(), delegate, web_contents); |
| 65 ASSERT_TRUE(dialog_delegate); | 65 ASSERT_TRUE(dialog_delegate); |
| 66 EXPECT_TRUE(dialog_delegate->GetNativeDialog()); | 66 EXPECT_TRUE(dialog_delegate->GetNativeDialog()); |
| 67 EXPECT_TRUE(IsShowingWebContentsModalDialog(web_contents)); | 67 EXPECT_TRUE(IsShowingWebContentsModalDialog(web_contents)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Tests that ReleaseWebContentsOnDialogClose() works. | 70 // Tests that ReleaseWebContentsOnDialogClose() works. |
| 71 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, | 71 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, |
| 72 ReleaseWebContentsOnDialogClose) { | 72 ReleaseWebContentsOnDialogClose) { |
| 73 // The delegate deletes itself. | 73 // The delegate deletes itself. |
| 74 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( | 74 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( |
| 75 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); | 75 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); |
| 76 WebContents* web_contents = | 76 WebContents* web_contents = |
| 77 browser()->tab_strip_model()->GetActiveWebContents(); | 77 browser()->tab_strip_model()->GetActiveWebContents(); |
| 78 ASSERT_TRUE(web_contents); | 78 ASSERT_TRUE(web_contents); |
| 79 | 79 |
| 80 ConstrainedWebDialogDelegate* dialog_delegate = | 80 ConstrainedWebDialogDelegate* dialog_delegate = |
| 81 CreateConstrainedWebDialog(browser()->profile(), delegate, web_contents); | 81 ShowConstrainedWebDialog(browser()->profile(), delegate, web_contents); |
| 82 ASSERT_TRUE(dialog_delegate); | 82 ASSERT_TRUE(dialog_delegate); |
| 83 scoped_ptr<WebContents> new_tab(dialog_delegate->GetWebContents()); | 83 scoped_ptr<WebContents> new_tab(dialog_delegate->GetWebContents()); |
| 84 ASSERT_TRUE(new_tab.get()); | 84 ASSERT_TRUE(new_tab.get()); |
| 85 ASSERT_TRUE(IsShowingWebContentsModalDialog(web_contents)); | 85 ASSERT_TRUE(IsShowingWebContentsModalDialog(web_contents)); |
| 86 | 86 |
| 87 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); | 87 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); |
| 88 dialog_delegate->ReleaseWebContentsOnDialogClose(); | 88 dialog_delegate->ReleaseWebContentsOnDialogClose(); |
| 89 dialog_delegate->OnDialogCloseFromWebUI(); | 89 dialog_delegate->OnDialogCloseFromWebUI(); |
| 90 | 90 |
| 91 ASSERT_FALSE(observer.contents_destroyed()); | 91 ASSERT_FALSE(observer.contents_destroyed()); |
| 92 EXPECT_FALSE(IsShowingWebContentsModalDialog(web_contents)); | 92 EXPECT_FALSE(IsShowingWebContentsModalDialog(web_contents)); |
| 93 new_tab.reset(); | 93 new_tab.reset(); |
| 94 EXPECT_TRUE(observer.contents_destroyed()); | 94 EXPECT_TRUE(observer.contents_destroyed()); |
| 95 } | 95 } |
| OLD | NEW |