Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc

Issue 538203002: Fix a crash on WebViewFocusHelper destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build; cleanup. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Tests that opening/closing the constrained window won't crash it. 57 // Tests that opening/closing the constrained window won't crash it.
58 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { 58 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) {
59 // The delegate deletes itself. 59 // The delegate deletes itself.
60 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( 60 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate(
61 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 61 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
62 WebContents* web_contents = 62 WebContents* web_contents =
63 browser()->tab_strip_model()->GetActiveWebContents(); 63 browser()->tab_strip_model()->GetActiveWebContents();
64 ASSERT_TRUE(web_contents); 64 ASSERT_TRUE(web_contents);
65 65
66 ConstrainedWebDialogDelegate* dialog_delegate = 66 ConstrainedWebDialogDelegate* dialog_delegate =
67 CreateConstrainedWebDialog(browser()->profile(), 67 CreateConstrainedWebDialog(browser()->profile(), delegate, web_contents);
68 delegate,
69 NULL,
70 web_contents);
71 ASSERT_TRUE(dialog_delegate); 68 ASSERT_TRUE(dialog_delegate);
72 EXPECT_TRUE(dialog_delegate->GetNativeDialog()); 69 EXPECT_TRUE(dialog_delegate->GetNativeDialog());
73 EXPECT_TRUE(IsShowingWebContentsModalDialog(web_contents)); 70 EXPECT_TRUE(IsShowingWebContentsModalDialog(web_contents));
74 } 71 }
75 72
76 // Tests that ReleaseWebContentsOnDialogClose() works. 73 // Tests that ReleaseWebContentsOnDialogClose() works.
77 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, 74 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
78 ReleaseWebContentsOnDialogClose) { 75 ReleaseWebContentsOnDialogClose) {
79 // The delegate deletes itself. 76 // The delegate deletes itself.
80 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate( 77 WebDialogDelegate* delegate = new ui::test::TestWebDialogDelegate(
81 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 78 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
82 WebContents* web_contents = 79 WebContents* web_contents =
83 browser()->tab_strip_model()->GetActiveWebContents(); 80 browser()->tab_strip_model()->GetActiveWebContents();
84 ASSERT_TRUE(web_contents); 81 ASSERT_TRUE(web_contents);
85 82
86 ConstrainedWebDialogDelegate* dialog_delegate = 83 ConstrainedWebDialogDelegate* dialog_delegate =
87 CreateConstrainedWebDialog(browser()->profile(), 84 CreateConstrainedWebDialog(browser()->profile(), delegate, web_contents);
88 delegate,
89 NULL,
90 web_contents);
91 ASSERT_TRUE(dialog_delegate); 85 ASSERT_TRUE(dialog_delegate);
92 scoped_ptr<WebContents> new_tab(dialog_delegate->GetWebContents()); 86 scoped_ptr<WebContents> new_tab(dialog_delegate->GetWebContents());
93 ASSERT_TRUE(new_tab.get()); 87 ASSERT_TRUE(new_tab.get());
94 ASSERT_TRUE(IsShowingWebContentsModalDialog(web_contents)); 88 ASSERT_TRUE(IsShowingWebContentsModalDialog(web_contents));
95 89
96 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get()); 90 ConstrainedWebDialogBrowserTestObserver observer(new_tab.get());
97 dialog_delegate->ReleaseWebContentsOnDialogClose(); 91 dialog_delegate->ReleaseWebContentsOnDialogClose();
98 dialog_delegate->OnDialogCloseFromWebUI(); 92 dialog_delegate->OnDialogCloseFromWebUI();
99 93
100 ASSERT_FALSE(observer.contents_destroyed()); 94 ASSERT_FALSE(observer.contents_destroyed());
101 EXPECT_FALSE(IsShowingWebContentsModalDialog(web_contents)); 95 EXPECT_FALSE(IsShowingWebContentsModalDialog(web_contents));
102 new_tab.reset(); 96 new_tab.reset();
103 EXPECT_TRUE(observer.contents_destroyed()); 97 EXPECT_TRUE(observer.contents_destroyed());
104 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698