Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / chrome / browser / ui / views / confirm_bubble_views_unittest.cc
blobcba17e997d133f175eb9100926365fd3d2b96543
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/chrome_constrained_window_views_client.h"
10 #include "components/constrained_window/constrained_window_views.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/views/test/views_test_base.h"
13 #include "ui/views/widget/widget.h"
15 using views::Widget;
17 typedef views::ViewsTestBase ConfirmBubbleViewsTest;
19 TEST_F(ConfirmBubbleViewsTest, CreateAndClose) {
20 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient());
22 // Create parent widget, as confirm bubble must have an owner.
23 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
24 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
25 scoped_ptr<views::Widget> parent_widget(new Widget);
26 parent_widget->Init(params);
27 parent_widget->Show();
29 // Bubble owns the model.
30 bool model_deleted = false;
31 scoped_ptr<TestConfirmBubbleModel> model(
32 new TestConfirmBubbleModel(&model_deleted, NULL, NULL, NULL));
33 ConfirmBubbleViews* bubble = new ConfirmBubbleViews(model.Pass());
34 gfx::NativeWindow parent = parent_widget->GetNativeWindow();
35 constrained_window::CreateBrowserModalDialogViews(bubble, parent)->Show();
37 // Clean up.
38 bubble->GetWidget()->CloseNow();
39 parent_widget->CloseNow();
40 EXPECT_TRUE(model_deleted);
42 constrained_window::SetConstrainedWindowViewsClient(nullptr);