summaryrefslogtreecommitdiffstats
path: root/components/mus/public/cpp/tests/test_window_tree.h
blob: 6db82a425db5a9826006b7dd70f4ad4be6e5c1f1 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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_MUS_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_
#define COMPONENTS_MUS_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_

#include "base/macros.h"
#include "components/mus/public/interfaces/window_tree.mojom.h"

namespace mus {

// Testing WindowTree implementation.
class TestWindowTree : public mojom::WindowTree {
 public:
  TestWindowTree();
  ~TestWindowTree() override;

  // Returns the most recent change_id supplied to one of the WindowTree
  // functions. Returns false if one of the WindowTree functions has not been
  // invoked since the last GetAndClearChangeId().
  bool GetAndClearChangeId(uint32_t* change_id);

 private:
  // mojom::WindowTree:
  void NewWindow(
      uint32_t change_id,
      uint32_t window_id,
      mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) override;
  void DeleteWindow(uint32_t change_id, uint32_t window_id) override;
  void SetWindowBounds(uint32_t change_id,
                       uint32_t window_id,
                       mojo::RectPtr bounds) override;
  void SetClientArea(uint32_t window_id, mojo::InsetsPtr insets) override;
  void SetWindowVisibility(
      uint32_t window_id,
      bool visible,
      const SetWindowVisibilityCallback& callback) override;
  void SetWindowProperty(uint32_t change_id,
                         uint32_t window_id,
                         const mojo::String& name,
                         mojo::Array<uint8_t> value) override;
  void AttachSurface(uint32_t window_id,
                     mojom::SurfaceType type,
                     mojo::InterfaceRequest<mojom::Surface> surface,
                     mojom::SurfaceClientPtr client) override;
  void AddWindow(uint32_t parent,
                 uint32_t child,
                 const AddWindowCallback& callback) override;
  void RemoveWindowFromParent(
      uint32_t window_id,
      const RemoveWindowFromParentCallback& callback) override;
  void AddTransientWindow(uint32_t change_id,
                          uint32_t window_id,
                          uint32_t transient_window_id) override;
  void RemoveTransientWindowFromParent(uint32_t change_id,
                                       uint32_t window_id) override;
  void ReorderWindow(uint32_t window_id,
                     uint32_t relative_window_id,
                     mojom::OrderDirection direction,
                     const ReorderWindowCallback& callback) override;
  void GetWindowTree(uint32_t window_id,
                     const GetWindowTreeCallback& callback) override;
  void Embed(uint32_t window_id,
             mojom::WindowTreeClientPtr client,
             uint32_t policy_bitmask,
             const EmbedCallback& callback) override;
  void SetFocus(uint32_t window_id) override;
  void SetCanFocus(uint32_t window_id, bool can_focus) override;
  void SetWindowTextInputState(uint32_t window_id,
                               mojo::TextInputStatePtr state) override;
  void SetImeVisibility(uint32_t window_id,
                        bool visible,
                        mojo::TextInputStatePtr state) override;
  void OnWindowInputEventAck(uint32_t event_id) override;
  void WmResponse(uint32_t change_id, bool response) override;

  bool got_change_;
  uint32_t change_id_;

  DISALLOW_COPY_AND_ASSIGN(TestWindowTree);
};

}  // namespace mus

#endif  // COMPONENTS_MUS_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_