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

Side by Side Diff: mojo/edk/system/core_test_base.h

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/core_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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 MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_
6 #define MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/synchronization/lock.h"
11 #include "mojo/public/c/system/types.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace mojo {
15 namespace system {
16
17 class Core;
18 class Awakable;
19
20 namespace test {
21
22 class CoreTestBase_MockHandleInfo;
23
24 class CoreTestBase : public testing::Test {
25 public:
26 typedef CoreTestBase_MockHandleInfo MockHandleInfo;
27
28 CoreTestBase();
29 ~CoreTestBase() override;
30
31 void SetUp() override;
32 void TearDown() override;
33
34 protected:
35 // |info| must remain alive until the returned handle is closed.
36 MojoHandle CreateMockHandle(MockHandleInfo* info);
37
38 Core* core() { return core_; }
39
40 private:
41 Core* core_;
42
43 DISALLOW_COPY_AND_ASSIGN(CoreTestBase);
44 };
45
46 class CoreTestBase_MockHandleInfo {
47 public:
48 CoreTestBase_MockHandleInfo();
49 ~CoreTestBase_MockHandleInfo();
50
51 unsigned GetCtorCallCount() const;
52 unsigned GetDtorCallCount() const;
53 unsigned GetCloseCallCount() const;
54 unsigned GetWriteMessageCallCount() const;
55 unsigned GetReadMessageCallCount() const;
56 unsigned GetWriteDataCallCount() const;
57 unsigned GetBeginWriteDataCallCount() const;
58 unsigned GetEndWriteDataCallCount() const;
59 unsigned GetReadDataCallCount() const;
60 unsigned GetBeginReadDataCallCount() const;
61 unsigned GetEndReadDataCallCount() const;
62 unsigned GetAddAwakableCallCount() const;
63 unsigned GetRemoveAwakableCallCount() const;
64 unsigned GetCancelAllAwakablesCallCount() const;
65
66 size_t GetAddedAwakableSize() const;
67 Awakable* GetAddedAwakableAt(unsigned i) const;
68
69 // For use by |MockDispatcher|:
70 void IncrementCtorCallCount();
71 void IncrementDtorCallCount();
72 void IncrementCloseCallCount();
73 void IncrementWriteMessageCallCount();
74 void IncrementReadMessageCallCount();
75 void IncrementWriteDataCallCount();
76 void IncrementBeginWriteDataCallCount();
77 void IncrementEndWriteDataCallCount();
78 void IncrementReadDataCallCount();
79 void IncrementBeginReadDataCallCount();
80 void IncrementEndReadDataCallCount();
81 void IncrementAddAwakableCallCount();
82 void IncrementRemoveAwakableCallCount();
83 void IncrementCancelAllAwakablesCallCount();
84
85 void AllowAddAwakable(bool alllow);
86 bool IsAddAwakableAllowed() const;
87 void AwakableWasAdded(Awakable*);
88
89 private:
90 mutable base::Lock lock_; // Protects the following members.
91 unsigned ctor_call_count_;
92 unsigned dtor_call_count_;
93 unsigned close_call_count_;
94 unsigned write_message_call_count_;
95 unsigned read_message_call_count_;
96 unsigned write_data_call_count_;
97 unsigned begin_write_data_call_count_;
98 unsigned end_write_data_call_count_;
99 unsigned read_data_call_count_;
100 unsigned begin_read_data_call_count_;
101 unsigned end_read_data_call_count_;
102 unsigned add_awakable_call_count_;
103 unsigned remove_awakable_call_count_;
104 unsigned cancel_all_awakables_call_count_;
105
106 bool add_awakable_allowed_;
107 std::vector<Awakable*> added_awakables_;
108
109 DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo);
110 };
111
112 } // namespace test
113 } // namespace system
114 } // namespace mojo
115
116 #endif // MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/core_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698