Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: components/view_manager/public/cpp/tests/view_manager_test_base.h

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #ifndef COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_
6 #define COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "components/view_manager/public/cpp/view_tree_delegate.h"
10 #include "components/view_manager/public/interfaces/view_tree.mojom.h"
11 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h"
12 #include "mojo/application/public/cpp/application_delegate.h"
13 #include "mojo/application/public/cpp/application_test_base.h"
14 #include "mojo/application/public/cpp/interface_factory.h"
15
16 namespace mojo {
17
18 // ViewManagerTestBase is a base class for use with app tests that use
19 // ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed()
20 // has been invoked. window_manager() can be used to access the ViewManager
21 // established as part of SetUp().
22 class ViewManagerTestBase : public test::ApplicationTestBase,
23 public ApplicationDelegate,
24 public ViewTreeDelegate,
25 public InterfaceFactory<ViewTreeClient> {
26 public:
27 ViewManagerTestBase();
28 ~ViewManagerTestBase() override;
29
30 // True if ViewTreeDelegate::OnConnectionLost() was called.
31 bool view_tree_connection_destroyed() const {
32 return view_tree_connection_destroyed_;
33 }
34
35 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs.
36 // Returns true on success. Generally prefer running a RunLoop and
37 // explicitly quiting that, but use this for times when that is not possible.
38 static bool DoRunLoopWithTimeout() WARN_UNUSED_RESULT;
39
40 // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on
41 // success, false if a RunLoop isn't running.
42 static bool QuitRunLoop() WARN_UNUSED_RESULT;
43
44 ViewTreeConnection* window_manager() { return window_manager_; }
45
46 protected:
47 ViewTreeConnection* most_recent_connection() {
48 return most_recent_connection_;
49 }
50
51 // testing::Test:
52 void SetUp() override;
53 void TearDown() override;
54
55 // test::ApplicationTestBase:
56 ApplicationDelegate* GetApplicationDelegate() override;
57
58 // ApplicationDelegate:
59 bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
60
61 // ViewTreeDelegate:
62 void OnEmbed(View* root) override;
63 void OnConnectionLost(ViewTreeConnection* connection) override;
64
65 // InterfaceFactory<ViewTreeClient>:
66 void Create(ApplicationConnection* connection,
67 InterfaceRequest<ViewTreeClient> request) override;
68
69 // Used to receive the most recent view tree connection loaded by an embed
70 // action.
71 ViewTreeConnection* most_recent_connection_;
72
73 private:
74 ViewTreeHostPtr host_;
75
76 // The View Manager connection held by the window manager (app running at the
77 // root view).
78 ViewTreeConnection* window_manager_;
79
80 bool view_tree_connection_destroyed_;
81
82 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase);
83 };
84
85 } // namespace mojo
86
87 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698