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