Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / chrome_bubble_manager_unittest.cc
blob4d96c54d287ca5bafed2e533775f3bb3ac98931c
1 // Copyright 2015 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/chrome_bubble_manager.h"
7 #include "chrome/browser/ui/tabs/tab_strip_model.h"
8 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h"
9 #include "chrome/test/base/testing_profile.h"
10 #include "components/bubble/bubble_controller.h"
11 #include "components/bubble/bubble_manager_mocks.h"
12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace {
17 class ChromeBubbleManagerTest : public testing::Test {
18 public:
19 ChromeBubbleManagerTest();
20 ~ChromeBubbleManagerTest() override;
22 // testing::Test:
23 void SetUp() override;
24 void TearDown() override;
26 protected:
27 scoped_ptr<TestingProfile> profile_;
28 scoped_ptr<TestTabStripModelDelegate> delegate_;
29 scoped_ptr<TabStripModel> tabstrip_;
30 scoped_ptr<ChromeBubbleManager> manager_;
32 private:
33 // ChromeBubbleManager expects to be on the UI thread.
34 content::TestBrowserThreadBundle thread_bundle_;
36 DISALLOW_COPY_AND_ASSIGN(ChromeBubbleManagerTest);
39 ChromeBubbleManagerTest::ChromeBubbleManagerTest()
40 : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT) {}
42 ChromeBubbleManagerTest::~ChromeBubbleManagerTest() {}
44 void ChromeBubbleManagerTest::SetUp() {
45 testing::Test::SetUp();
47 profile_.reset(new TestingProfile);
48 delegate_.reset(new TestTabStripModelDelegate);
49 tabstrip_.reset(new TabStripModel(delegate_.get(), profile_.get()));
50 manager_.reset(new ChromeBubbleManager(tabstrip_.get()));
53 void ChromeBubbleManagerTest::TearDown() {
54 manager_.reset();
55 tabstrip_.reset();
56 delegate_.reset();
57 profile_.reset();
58 testing::Test::TearDown();
61 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnDestroy) {
62 BubbleReference bubble1 = manager_->ShowBubble(MockBubbleDelegate::Default());
63 manager_.reset();
64 ASSERT_FALSE(bubble1);
67 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleForTwoDifferentReasons) {
68 BubbleReference bubble1 = manager_->ShowBubble(MockBubbleDelegate::Default());
69 BubbleReference bubble2 = manager_->ShowBubble(MockBubbleDelegate::Default());
71 bubble1->CloseBubble(BUBBLE_CLOSE_ACCEPTED);
72 bubble2->CloseBubble(BUBBLE_CLOSE_CANCELED);
74 ASSERT_FALSE(bubble1);
75 ASSERT_FALSE(bubble2);
78 } // namespace