[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / confirm_bubble_views_unittest.cc
blobc5ed354db8f2b5e858c2321477e30f0b031cd91f
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"
14 using views::Widget;
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();
34 // Clean up.
35 bubble->GetWidget()->CloseNow();
36 parent_widget->CloseNow();
37 EXPECT_TRUE(model_deleted);