| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/ui/views/confirm_bubble_views.h" | 5 #include "chrome/browser/ui/views/confirm_bubble_views.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/confirm_bubble.h" | 9 #include "chrome/browser/ui/confirm_bubble.h" |
| 10 #include "chrome/browser/ui/test/test_confirm_bubble_model.h" | 10 #include "chrome/browser/ui/test/test_confirm_bubble_model.h" |
| 11 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" | 11 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" |
| 12 #include "components/constrained_window/constrained_window_views.h" | 12 #include "components/constrained_window/constrained_window_views.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/views/test/views_test_base.h" | 14 #include "ui/views/test/views_test_base.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 | 16 |
| 17 using views::Widget; | 17 using views::Widget; |
| 18 | 18 |
| 19 typedef views::ViewsTestBase ConfirmBubbleViewsTest; | 19 typedef views::ViewsTestBase ConfirmBubbleViewsTest; |
| 20 | 20 |
| 21 TEST_F(ConfirmBubbleViewsTest, CreateAndClose) { | 21 TEST_F(ConfirmBubbleViewsTest, CreateAndClose) { |
| 22 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); | 22 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); |
| 23 | 23 |
| 24 // Create parent widget, as confirm bubble must have an owner. | 24 // Create parent widget, as confirm bubble must have an owner. |
| 25 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 25 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 26 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 26 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 27 scoped_ptr<views::Widget> parent_widget(new Widget); | 27 std::unique_ptr<views::Widget> parent_widget(new Widget); |
| 28 parent_widget->Init(params); | 28 parent_widget->Init(params); |
| 29 parent_widget->Show(); | 29 parent_widget->Show(); |
| 30 | 30 |
| 31 // Bubble owns the model. | 31 // Bubble owns the model. |
| 32 bool model_deleted = false; | 32 bool model_deleted = false; |
| 33 scoped_ptr<TestConfirmBubbleModel> model( | 33 std::unique_ptr<TestConfirmBubbleModel> model( |
| 34 new TestConfirmBubbleModel(&model_deleted, NULL, NULL, NULL)); | 34 new TestConfirmBubbleModel(&model_deleted, NULL, NULL, NULL)); |
| 35 ConfirmBubbleViews* bubble = new ConfirmBubbleViews(std::move(model)); | 35 ConfirmBubbleViews* bubble = new ConfirmBubbleViews(std::move(model)); |
| 36 gfx::NativeWindow parent = parent_widget->GetNativeWindow(); | 36 gfx::NativeWindow parent = parent_widget->GetNativeWindow(); |
| 37 constrained_window::CreateBrowserModalDialogViews(bubble, parent)->Show(); | 37 constrained_window::CreateBrowserModalDialogViews(bubble, parent)->Show(); |
| 38 | 38 |
| 39 // Clean up. | 39 // Clean up. |
| 40 bubble->GetWidget()->CloseNow(); | 40 bubble->GetWidget()->CloseNow(); |
| 41 parent_widget->CloseNow(); | 41 parent_widget->CloseNow(); |
| 42 EXPECT_TRUE(model_deleted); | 42 EXPECT_TRUE(model_deleted); |
| 43 | 43 |
| 44 constrained_window::SetConstrainedWindowViewsClient(nullptr); | 44 constrained_window::SetConstrainedWindowViewsClient(nullptr); |
| 45 } | 45 } |
| OLD | NEW |