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

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

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup Created 5 years, 2 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ 5 #ifndef MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_
6 #define THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ 6 #define MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_
7 7
8 #include "base/synchronization/lock.h"
9 #include "mojo/edk/embedder/embedder_internal.h"
10 #include "mojo/edk/system/test_utils.h"
8 #include "mojo/public/c/system/types.h" 11 #include "mojo/public/c/system/types.h"
9 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h"
12 #include "third_party/mojo/src/mojo/edk/system/mutex.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 namespace system { 16 namespace edk {
16 17
17 class Core; 18 class Core;
18 class Awakable; 19 class Awakable;
19 20
20 namespace test { 21 namespace test {
21 22
22 class CoreTestBase_MockHandleInfo; 23 class CoreTestBase_MockHandleInfo;
23 24
24 class CoreTestBase : public testing::Test { 25 class CoreTestBase : public MojoSystemTest {
25 public: 26 public:
26 using MockHandleInfo = CoreTestBase_MockHandleInfo; 27 using MockHandleInfo = CoreTestBase_MockHandleInfo;
27 28
28 CoreTestBase(); 29 CoreTestBase();
29 ~CoreTestBase() override; 30 ~CoreTestBase() override;
30 31
31 void SetUp() override;
32 void TearDown() override;
33
34 protected: 32 protected:
35 // |info| must remain alive until the returned handle is closed. 33 // |info| must remain alive until the returned handle is closed.
36 MojoHandle CreateMockHandle(MockHandleInfo* info); 34 MojoHandle CreateMockHandle(MockHandleInfo* info);
37 35
38 Core* core() { return core_; } 36 Core* core() { return mojo::edk::internal::g_core; }
39 37
40 private: 38 private:
41 embedder::SimplePlatformSupport platform_support_;
42 Core* core_;
43
44 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase); 39 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase);
45 }; 40 };
46 41
47 class CoreTestBase_MockHandleInfo { 42 class CoreTestBase_MockHandleInfo {
48 public: 43 public:
49 CoreTestBase_MockHandleInfo(); 44 CoreTestBase_MockHandleInfo();
50 ~CoreTestBase_MockHandleInfo(); 45 ~CoreTestBase_MockHandleInfo();
51 46
52 unsigned GetCtorCallCount() const; 47 unsigned GetCtorCallCount() const;
53 unsigned GetDtorCallCount() const; 48 unsigned GetDtorCallCount() const;
(...skipping 27 matching lines...) Expand all
81 void IncrementEndReadDataCallCount(); 76 void IncrementEndReadDataCallCount();
82 void IncrementAddAwakableCallCount(); 77 void IncrementAddAwakableCallCount();
83 void IncrementRemoveAwakableCallCount(); 78 void IncrementRemoveAwakableCallCount();
84 void IncrementCancelAllAwakablesCallCount(); 79 void IncrementCancelAllAwakablesCallCount();
85 80
86 void AllowAddAwakable(bool alllow); 81 void AllowAddAwakable(bool alllow);
87 bool IsAddAwakableAllowed() const; 82 bool IsAddAwakableAllowed() const;
88 void AwakableWasAdded(Awakable*); 83 void AwakableWasAdded(Awakable*);
89 84
90 private: 85 private:
91 mutable Mutex mutex_; 86 mutable base::Lock lock_; // Protects the following members.
92 unsigned ctor_call_count_ MOJO_GUARDED_BY(mutex_); 87 unsigned ctor_call_count_;
93 unsigned dtor_call_count_ MOJO_GUARDED_BY(mutex_); 88 unsigned dtor_call_count_;
94 unsigned close_call_count_ MOJO_GUARDED_BY(mutex_); 89 unsigned close_call_count_;
95 unsigned write_message_call_count_ MOJO_GUARDED_BY(mutex_); 90 unsigned write_message_call_count_;
96 unsigned read_message_call_count_ MOJO_GUARDED_BY(mutex_); 91 unsigned read_message_call_count_;
97 unsigned write_data_call_count_ MOJO_GUARDED_BY(mutex_); 92 unsigned write_data_call_count_;
98 unsigned begin_write_data_call_count_ MOJO_GUARDED_BY(mutex_); 93 unsigned begin_write_data_call_count_;
99 unsigned end_write_data_call_count_ MOJO_GUARDED_BY(mutex_); 94 unsigned end_write_data_call_count_;
100 unsigned read_data_call_count_ MOJO_GUARDED_BY(mutex_); 95 unsigned read_data_call_count_;
101 unsigned begin_read_data_call_count_ MOJO_GUARDED_BY(mutex_); 96 unsigned begin_read_data_call_count_;
102 unsigned end_read_data_call_count_ MOJO_GUARDED_BY(mutex_); 97 unsigned end_read_data_call_count_;
103 unsigned add_awakable_call_count_ MOJO_GUARDED_BY(mutex_); 98 unsigned add_awakable_call_count_;
104 unsigned remove_awakable_call_count_ MOJO_GUARDED_BY(mutex_); 99 unsigned remove_awakable_call_count_;
105 unsigned cancel_all_awakables_call_count_ MOJO_GUARDED_BY(mutex_); 100 unsigned cancel_all_awakables_call_count_;
106 101
107 bool add_awakable_allowed_ MOJO_GUARDED_BY(mutex_); 102 bool add_awakable_allowed_;
108 std::vector<Awakable*> added_awakables_ MOJO_GUARDED_BY(mutex_); 103 std::vector<Awakable*> added_awakables_;
109 104
110 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo); 105 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo);
111 }; 106 };
112 107
113 } // namespace test 108 } // namespace test
114 } // namespace system 109 } // namespace edk
115 } // namespace mojo 110 } // namespace mojo
116 111
117 #endif // THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ 112 #endif // MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698