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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/confirm_bubble_views.h"
7 #include "chrome/browser/ui/confirm_bubble.h"
8 #include "chrome/browser/ui/test/test_confirm_bubble_model.h"
9 #include "chrome/browser/ui/views/constrained_window_views.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/widget.h"
16 typedef views::ViewsTestBase ConfirmBubbleViewsTest
;
18 TEST_F(ConfirmBubbleViewsTest
, CreateAndClose
) {
19 // Create parent widget, as confirm bubble must have an owner.
20 Widget::InitParams params
= CreateParams(Widget::InitParams::TYPE_WINDOW
);
21 params
.ownership
= views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET
;
22 scoped_ptr
<views::Widget
> parent_widget(new Widget
);
23 parent_widget
->Init(params
);
24 parent_widget
->Show();
26 // Bubble owns the model.
27 bool model_deleted
= false;
28 TestConfirmBubbleModel
* model
=
29 new TestConfirmBubbleModel(&model_deleted
, NULL
, NULL
, NULL
);
30 ConfirmBubbleViews
* bubble
= new ConfirmBubbleViews(model
);
31 gfx::NativeView parent
= parent_widget
->GetNativeView();
32 CreateBrowserModalDialogViews(bubble
, parent
)->Show();
35 bubble
->GetWidget()->CloseNow();
36 parent_widget
->CloseNow();
37 EXPECT_TRUE(model_deleted
);