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