OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/webview/webview.h" | 5 #include "ui/views/controls/webview/webview.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 OnMousePressed(click_inside_holder)); | 460 OnMousePressed(click_inside_holder)); |
461 EXPECT_FALSE(web_view()->HasFocus()); | 461 EXPECT_FALSE(web_view()->HasFocus()); |
462 EXPECT_FALSE(holder()->HasFocus()); | 462 EXPECT_FALSE(holder()->HasFocus()); |
463 EXPECT_TRUE(something_to_focus->HasFocus()); | 463 EXPECT_TRUE(something_to_focus->HasFocus()); |
464 } | 464 } |
465 | 465 |
466 // Verifies that there is no crash in WebView destructor | 466 // Verifies that there is no crash in WebView destructor |
467 // if WebView is already removed from Widget. | 467 // if WebView is already removed from Widget. |
468 TEST_F(WebViewUnitTest, DetachedWebViewDestructor) { | 468 TEST_F(WebViewUnitTest, DetachedWebViewDestructor) { |
469 // Init WebView with attached NativeView. | 469 // Init WebView with attached NativeView. |
470 const scoped_ptr<content::WebContents> web_contents(CreateWebContents()); | 470 const std::unique_ptr<content::WebContents> web_contents(CreateWebContents()); |
471 scoped_ptr<WebView> webview(new WebView(web_contents->GetBrowserContext())); | 471 std::unique_ptr<WebView> webview( |
| 472 new WebView(web_contents->GetBrowserContext())); |
472 View* contents_view = top_level_widget()->GetContentsView(); | 473 View* contents_view = top_level_widget()->GetContentsView(); |
473 contents_view->AddChildView(webview.get()); | 474 contents_view->AddChildView(webview.get()); |
474 webview->SetWebContents(web_contents.get()); | 475 webview->SetWebContents(web_contents.get()); |
475 | 476 |
476 // Remove WebView from views hierarchy. NativeView should be detached | 477 // Remove WebView from views hierarchy. NativeView should be detached |
477 // from Widget. | 478 // from Widget. |
478 contents_view->RemoveChildView(webview.get()); | 479 contents_view->RemoveChildView(webview.get()); |
479 // Destroy WebView. NativeView should be detached secondary. | 480 // Destroy WebView. NativeView should be detached secondary. |
480 // There should be no crash. | 481 // There should be no crash. |
481 webview.reset(); | 482 webview.reset(); |
482 } | 483 } |
483 | 484 |
484 } // namespace views | 485 } // namespace views |
OLD | NEW |