| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #include "components/bubble/bubble_manager.h" |
| 6 |
| 7 #include "components/bubble/bubble_builder.h" |
| 8 #include "components/bubble/bubble_delegate.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 class DelegateMock : public BubbleDelegate { |
| 15 public: |
| 16 MOCK_METHOD0(OnShow, void()); |
| 17 MOCK_METHOD0(OnHide, void()); |
| 18 MOCK_METHOD0(OnUpdatePosition, void()); |
| 19 MOCK_METHOD1(BuildBubble, void(BubbleBuilder*)); |
| 20 }; |
| 21 |
| 22 class BubbleManagerUnittest : public testing::Test {}; |
| 23 |
| 24 // Simple test to show and hide a bubble. |
| 25 TEST_F(BubbleManagerUnittest, ShowAndHideBubble) { |
| 26 BubbleManager manager; |
| 27 |
| 28 DelegateMock delegate; |
| 29 EXPECT_CALL(delegate, OnShow()).Times(1); |
| 30 EXPECT_CALL(delegate, OnHide()).Times(1); |
| 31 |
| 32 manager.ShowBubble(&delegate); |
| 33 manager.HideBubble(&delegate); |
| 34 } |
| 35 |
| 36 // Simple test to show and hide more than one bubble. |
| 37 TEST_F(BubbleManagerUnittest, ShowAndHide2Bubbles) { |
| 38 BubbleManager manager; |
| 39 |
| 40 DelegateMock delegate1, |
| 41 delegate2; |
| 42 |
| 43 EXPECT_CALL(delegate1, OnShow()).Times(1); |
| 44 EXPECT_CALL(delegate1, OnHide()).Times(1); |
| 45 |
| 46 EXPECT_CALL(delegate2, OnShow()).Times(1); |
| 47 EXPECT_CALL(delegate2, OnHide()).Times(1); |
| 48 |
| 49 manager.ShowBubble(&delegate1); |
| 50 manager.ShowBubble(&delegate2); |
| 51 |
| 52 manager.HideBubble(&delegate1); |
| 53 manager.HideBubble(&delegate2); |
| 54 } |
| 55 |
| 56 } // namespace |
| OLD | NEW |