| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/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/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { | 47 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { |
| 48 public: | 48 public: |
| 49 ConstrainedWebDialogBrowserTest() {} | 49 ConstrainedWebDialogBrowserTest() {} |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 bool IsShowingWebContentsModalDialog(WebContents* web_contents) const { | 52 bool IsShowingWebContentsModalDialog(WebContents* web_contents) const { |
| 53 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 53 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 54 WebContentsModalDialogManager::FromWebContents(web_contents); | 54 WebContentsModalDialogManager::FromWebContents(web_contents); |
| 55 return web_contents_modal_dialog_manager->IsShowingDialog(); | 55 return web_contents_modal_dialog_manager->IsDialogActive(); |
| 56 } | 56 } |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Tests that opening/closing the constrained window won't crash it. | 59 // Tests that opening/closing the constrained window won't crash it. |
| 60 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { | 60 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { |
| 61 // The delegate deletes itself. | 61 // The delegate deletes itself. |
| 62 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( | 62 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( |
| 63 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); | 63 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); |
| 64 WebContents* web_contents = | 64 WebContents* web_contents = |
| 65 browser()->tab_strip_model()->GetActiveWebContents(); | 65 browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); | 98 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); |
| 99 dialog_delegate->ReleaseWebContentsOnDialogClose(); | 99 dialog_delegate->ReleaseWebContentsOnDialogClose(); |
| 100 dialog_delegate->OnDialogCloseFromWebUI(); | 100 dialog_delegate->OnDialogCloseFromWebUI(); |
| 101 | 101 |
| 102 ASSERT_FALSE(observer.contents_destroyed()); | 102 ASSERT_FALSE(observer.contents_destroyed()); |
| 103 EXPECT_FALSE(IsShowingWebContentsModalDialog(web_contents)); | 103 EXPECT_FALSE(IsShowingWebContentsModalDialog(web_contents)); |
| 104 new_tab.reset(); | 104 new_tab.reset(); |
| 105 EXPECT_TRUE(observer.contents_destroyed()); | 105 EXPECT_TRUE(observer.contents_destroyed()); |
| 106 } | 106 } |
| OLD | NEW |