1 // Copyright (c) 2012 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/search_engines/template_url_service_factory.h"
6 #include "chrome/browser/ui/views/first_run_bubble.h"
7 #include "chrome/test/base/testing_profile.h"
8 #include "components/search_engines/template_url.h"
9 #include "components/search_engines/template_url_service.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/view.h"
13 #include "ui/views/widget/widget.h"
15 class FirstRunBubbleTest
: public views::ViewsTestBase
{
18 ~FirstRunBubbleTest() override
;
20 // Overrides from views::ViewsTestBase:
21 void SetUp() override
;
24 TestingProfile
* profile() { return &profile_
; }
27 TestingProfile profile_
;
29 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleTest
);
32 FirstRunBubbleTest::FirstRunBubbleTest() {}
33 FirstRunBubbleTest::~FirstRunBubbleTest() {}
35 void FirstRunBubbleTest::SetUp() {
36 ViewsTestBase::SetUp();
37 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
38 &profile_
, &TemplateURLServiceFactory::BuildInstanceFor
);
39 TemplateURLService
* turl_model
=
40 TemplateURLServiceFactory::GetForProfile(&profile_
);
44 TEST_F(FirstRunBubbleTest
, CreateAndClose
) {
45 // Create the anchor and parent widgets.
46 views::Widget::InitParams params
=
47 CreateParams(views::Widget::InitParams::TYPE_WINDOW
);
48 params
.ownership
= views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET
;
49 scoped_ptr
<views::Widget
> anchor_widget(new views::Widget
);
50 anchor_widget
->Init(params
);
51 anchor_widget
->Show();
53 FirstRunBubble
* delegate
=
54 FirstRunBubble::ShowBubble(NULL
, anchor_widget
->GetContentsView());
55 EXPECT_TRUE(delegate
!= NULL
);
56 delegate
->GetWidget()->CloseNow();