Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / views / first_run_bubble_unittest.cc
blob83c1b9c1f2b339b4325748a2b1ff66dd6e7f7f3d
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_browser_process.h"
8 #include "chrome/test/base/testing_profile.h"
9 #include "components/search_engines/template_url.h"
10 #include "components/search_engines/template_url_service.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/views/test/views_test_base.h"
13 #include "ui/views/view.h"
14 #include "ui/views/widget/widget.h"
16 class FirstRunBubbleTest : public views::ViewsTestBase {
17 public:
18 FirstRunBubbleTest();
19 ~FirstRunBubbleTest() override;
21 // Overrides from views::ViewsTestBase:
22 void SetUp() override;
23 void TearDown() override;
25 protected:
26 TestingProfile* profile() { return profile_.get(); }
28 private:
29 scoped_ptr<TestingProfile> profile_;
31 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleTest);
34 FirstRunBubbleTest::FirstRunBubbleTest() {}
35 FirstRunBubbleTest::~FirstRunBubbleTest() {}
37 void FirstRunBubbleTest::SetUp() {
38 ViewsTestBase::SetUp();
39 profile_.reset(new TestingProfile());
40 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
41 profile_.get(), &TemplateURLServiceFactory::BuildInstanceFor);
42 TemplateURLService* turl_model =
43 TemplateURLServiceFactory::GetForProfile(profile_.get());
44 turl_model->Load();
47 void FirstRunBubbleTest::TearDown() {
48 ViewsTestBase::TearDown();
49 profile_.reset();
50 TestingBrowserProcess::DeleteInstance();
53 TEST_F(FirstRunBubbleTest, CreateAndClose) {
54 // Create the anchor and parent widgets.
55 views::Widget::InitParams params =
56 CreateParams(views::Widget::InitParams::TYPE_WINDOW);
57 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
58 scoped_ptr<views::Widget> anchor_widget(new views::Widget);
59 anchor_widget->Init(params);
60 anchor_widget->Show();
62 FirstRunBubble* delegate =
63 FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView());
64 EXPECT_TRUE(delegate != NULL);
65 delegate->GetWidget()->CloseNow();