summaryrefslogtreecommitdiffstats
path: root/components/bubble/bubble_manager_mocks.h
blob: d181b4fd38a0aa0d9ef5497c402fd3f88c1e0b4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_
#define COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_

#include <utility>

#include "base/macros.h"
#include "components/bubble/bubble_delegate.h"
#include "components/bubble/bubble_reference.h"
#include "components/bubble/bubble_ui.h"
#include "testing/gmock/include/gmock/gmock.h"

class MockBubbleUi : public BubbleUi {
 public:
  MockBubbleUi();
  ~MockBubbleUi() override;

  MOCK_METHOD1(Show, void(BubbleReference));
  MOCK_METHOD0(Close, void());
  MOCK_METHOD0(UpdateAnchorPosition, void());

  // To verify destructor call.
  MOCK_METHOD0(Destroyed, void());

 private:
  DISALLOW_COPY_AND_ASSIGN(MockBubbleUi);
};

class MockBubbleDelegate : public BubbleDelegate {
 public:
  MockBubbleDelegate();
  ~MockBubbleDelegate() override;

  // Default bubble shows UI and closes when asked to close.
  static scoped_ptr<MockBubbleDelegate> Default();

  // Stubborn bubble shows UI and doesn't want to close.
  static scoped_ptr<MockBubbleDelegate> Stubborn();

  MOCK_CONST_METHOD1(ShouldClose, bool(BubbleCloseReason reason));
  MOCK_METHOD0(DidClose, void());

  // A scoped_ptr can't be returned in MOCK_METHOD.
  scoped_ptr<BubbleUi> BuildBubbleUi() override {
    return std::move(bubble_ui_);
  }

  MOCK_METHOD1(UpdateBubbleUi, bool(BubbleUi*));

  std::string GetName() const override { return "MockBubble"; }

  // To verify destructor call.
  MOCK_METHOD0(Destroyed, void());

  // Will be null after |BubbleManager::ShowBubble| is called.
  MockBubbleUi* bubble_ui() { return bubble_ui_.get(); }

 private:
  scoped_ptr<MockBubbleUi> bubble_ui_;

  DISALLOW_COPY_AND_ASSIGN(MockBubbleDelegate);
};

#endif  // COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_