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

Unified Diff: ui/views/controls/webview/webview_unittest.cc

Issue 584743004: Fix a crash which occurs while dragging tabs back to the window where they originated from. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/webview/webview.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/webview/webview_unittest.cc
diff --git a/ui/views/controls/webview/webview_unittest.cc b/ui/views/controls/webview/webview_unittest.cc
index 12012ca13e023231030d4702171720c9e72a646f..a6a250deb577b032599a8d3ddbcdf2f42de6c613 100644
--- a/ui/views/controls/webview/webview_unittest.cc
+++ b/ui/views/controls/webview/webview_unittest.cc
@@ -102,6 +102,8 @@ class WebViewTestWebContentsObserver : public content::WebContentsObserver {
}
virtual void WasShown() OVERRIDE {
+ valid_root_while_shown_ =
+ web_contents()->GetNativeView()->GetRootWindow() != NULL;
was_shown_ = true;
++shown_count_;
}
@@ -117,11 +119,15 @@ class WebViewTestWebContentsObserver : public content::WebContentsObserver {
int hidden_count() const { return hidden_count_; }
+ bool valid_root_while_shown() const { return valid_root_while_shown_; }
+
private:
content::WebContentsImpl* web_contents_;
bool was_shown_;
int32 shown_count_;
int32 hidden_count_;
+ // Set to true if the view containing the webcontents has a valid root window.
+ bool valid_root_while_shown_;
DISALLOW_COPY_AND_ASSIGN(WebViewTestWebContentsObserver);
};
@@ -149,6 +155,7 @@ TEST_F(WebViewUnitTest, TestWebViewAttachDetachWebContents) {
EXPECT_TRUE(web_contents1->GetNativeView()->IsVisible());
EXPECT_EQ(observer1.shown_count(), 1);
EXPECT_EQ(observer1.hidden_count(), 0);
+ EXPECT_TRUE(observer1.valid_root_while_shown());
// Case 2: Create another WebContents and replace the current WebContents
// via SetWebContents(). This should hide the current WebContents and show
@@ -156,6 +163,7 @@ TEST_F(WebViewUnitTest, TestWebViewAttachDetachWebContents) {
content::WebContents::CreateParams params2(browser_context());
scoped_ptr<content::WebContents> web_contents2(
content::WebContents::Create(params2));
+
WebViewTestWebContentsObserver observer2(web_contents2.get());
EXPECT_FALSE(observer2.was_shown());
@@ -163,6 +171,7 @@ TEST_F(WebViewUnitTest, TestWebViewAttachDetachWebContents) {
webview->SetWebContents(web_contents2.get());
EXPECT_FALSE(observer1.was_shown());
EXPECT_TRUE(observer2.was_shown());
+ EXPECT_TRUE(observer2.valid_root_while_shown());
// WebContents1 should not get stray show calls when WebContents2 is set.
EXPECT_EQ(observer1.shown_count(), 1);
« no previous file with comments | « ui/views/controls/webview/webview.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698