| OLD | NEW |
| 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 MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ |
| 6 #define MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ | 6 #define MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "mojo/edk/util/mutex.h" | 10 #include "mojo/edk/util/mutex.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE | | 39 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE | |
| 40 MOJO_HANDLE_RIGHT_MAP_EXECUTABLE; | 40 MOJO_HANDLE_RIGHT_MAP_EXECUTABLE; |
| 41 | 41 |
| 42 CoreTestBase(); | 42 CoreTestBase(); |
| 43 ~CoreTestBase() override; | 43 ~CoreTestBase() override; |
| 44 | 44 |
| 45 void SetUp() override; | 45 void SetUp() override; |
| 46 void TearDown() override; | 46 void TearDown() override; |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 // |info| must remain alive until the returned handle is closed. | 49 // |info| must remain alive until the returned handle and any handles |
| 50 // duplicated from it are closed. |
| 50 MojoHandle CreateMockHandle(MockHandleInfo* info); | 51 MojoHandle CreateMockHandle(MockHandleInfo* info); |
| 51 | 52 |
| 52 Core* core() { return core_.get(); } | 53 Core* core() { return core_.get(); } |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 std::unique_ptr<embedder::PlatformSupport> platform_support_; | 56 std::unique_ptr<embedder::PlatformSupport> platform_support_; |
| 56 std::unique_ptr<Core> core_; | 57 std::unique_ptr<Core> core_; |
| 57 | 58 |
| 58 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase); | 59 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 class CoreTestBase_MockHandleInfo { | 62 class CoreTestBase_MockHandleInfo { |
| 62 public: | 63 public: |
| 63 CoreTestBase_MockHandleInfo(); | 64 CoreTestBase_MockHandleInfo(); |
| 64 ~CoreTestBase_MockHandleInfo(); | 65 ~CoreTestBase_MockHandleInfo(); |
| 65 | 66 |
| 66 unsigned GetCtorCallCount() const; | 67 unsigned GetCtorCallCount() const; |
| 67 unsigned GetDtorCallCount() const; | 68 unsigned GetDtorCallCount() const; |
| 68 unsigned GetCloseCallCount() const; | 69 unsigned GetCloseCallCount() const; |
| 70 unsigned GetDuplicateDispatcherCallCount() const; |
| 69 unsigned GetWriteMessageCallCount() const; | 71 unsigned GetWriteMessageCallCount() const; |
| 70 unsigned GetReadMessageCallCount() const; | 72 unsigned GetReadMessageCallCount() const; |
| 71 unsigned GetWriteDataCallCount() const; | 73 unsigned GetWriteDataCallCount() const; |
| 72 unsigned GetBeginWriteDataCallCount() const; | 74 unsigned GetBeginWriteDataCallCount() const; |
| 73 unsigned GetEndWriteDataCallCount() const; | 75 unsigned GetEndWriteDataCallCount() const; |
| 74 unsigned GetReadDataCallCount() const; | 76 unsigned GetReadDataCallCount() const; |
| 75 unsigned GetBeginReadDataCallCount() const; | 77 unsigned GetBeginReadDataCallCount() const; |
| 76 unsigned GetEndReadDataCallCount() const; | 78 unsigned GetEndReadDataCallCount() const; |
| 77 unsigned GetDuplicateBufferHandleCallCount() const; | 79 unsigned GetDuplicateBufferHandleCallCount() const; |
| 78 unsigned GetGetBufferInformationCallCount() const; | 80 unsigned GetGetBufferInformationCallCount() const; |
| 79 unsigned GetMapBufferCallCount() const; | 81 unsigned GetMapBufferCallCount() const; |
| 80 unsigned GetAddAwakableCallCount() const; | 82 unsigned GetAddAwakableCallCount() const; |
| 81 unsigned GetRemoveAwakableCallCount() const; | 83 unsigned GetRemoveAwakableCallCount() const; |
| 82 unsigned GetCancelAllAwakablesCallCount() const; | 84 unsigned GetCancelAllAwakablesCallCount() const; |
| 83 | 85 |
| 84 size_t GetAddedAwakableSize() const; | 86 size_t GetAddedAwakableSize() const; |
| 85 Awakable* GetAddedAwakableAt(unsigned i) const; | 87 Awakable* GetAddedAwakableAt(unsigned i) const; |
| 86 | 88 |
| 87 // For use by |MockDispatcher|: | 89 // For use by |MockDispatcher|: |
| 88 void IncrementCtorCallCount(); | 90 void IncrementCtorCallCount(); |
| 89 void IncrementDtorCallCount(); | 91 void IncrementDtorCallCount(); |
| 90 void IncrementCloseCallCount(); | 92 void IncrementCloseCallCount(); |
| 93 void IncrementDuplicateDispatcherCallCount(); |
| 91 void IncrementWriteMessageCallCount(); | 94 void IncrementWriteMessageCallCount(); |
| 92 void IncrementReadMessageCallCount(); | 95 void IncrementReadMessageCallCount(); |
| 93 void IncrementWriteDataCallCount(); | 96 void IncrementWriteDataCallCount(); |
| 94 void IncrementBeginWriteDataCallCount(); | 97 void IncrementBeginWriteDataCallCount(); |
| 95 void IncrementEndWriteDataCallCount(); | 98 void IncrementEndWriteDataCallCount(); |
| 96 void IncrementReadDataCallCount(); | 99 void IncrementReadDataCallCount(); |
| 97 void IncrementBeginReadDataCallCount(); | 100 void IncrementBeginReadDataCallCount(); |
| 98 void IncrementEndReadDataCallCount(); | 101 void IncrementEndReadDataCallCount(); |
| 99 void IncrementDuplicateBufferHandleCallCount(); | 102 void IncrementDuplicateBufferHandleCallCount(); |
| 100 void IncrementGetBufferInformationCallCount(); | 103 void IncrementGetBufferInformationCallCount(); |
| 101 void IncrementMapBufferCallCount(); | 104 void IncrementMapBufferCallCount(); |
| 102 void IncrementAddAwakableCallCount(); | 105 void IncrementAddAwakableCallCount(); |
| 103 void IncrementRemoveAwakableCallCount(); | 106 void IncrementRemoveAwakableCallCount(); |
| 104 void IncrementCancelAllAwakablesCallCount(); | 107 void IncrementCancelAllAwakablesCallCount(); |
| 105 | 108 |
| 106 void AllowAddAwakable(bool alllow); | 109 void AllowAddAwakable(bool alllow); |
| 107 bool IsAddAwakableAllowed() const; | 110 bool IsAddAwakableAllowed() const; |
| 108 void AwakableWasAdded(Awakable*); | 111 void AwakableWasAdded(Awakable*); |
| 109 | 112 |
| 110 private: | 113 private: |
| 111 mutable util::Mutex mutex_; | 114 mutable util::Mutex mutex_; |
| 112 unsigned ctor_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 115 unsigned ctor_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 113 unsigned dtor_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 116 unsigned dtor_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 114 unsigned close_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 117 unsigned close_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 118 unsigned duplicate_dispatcher_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 115 unsigned write_message_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 119 unsigned write_message_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 116 unsigned read_message_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 120 unsigned read_message_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 117 unsigned write_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 121 unsigned write_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 118 unsigned begin_write_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 122 unsigned begin_write_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 119 unsigned end_write_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 123 unsigned end_write_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 120 unsigned read_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 124 unsigned read_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 121 unsigned begin_read_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 125 unsigned begin_read_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 122 unsigned end_read_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 126 unsigned end_read_data_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 123 unsigned duplicate_buffer_handle_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 127 unsigned duplicate_buffer_handle_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 124 unsigned get_buffer_information_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 128 unsigned get_buffer_information_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 125 unsigned map_buffer_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 129 unsigned map_buffer_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 126 unsigned add_awakable_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 130 unsigned add_awakable_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 127 unsigned remove_awakable_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 131 unsigned remove_awakable_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 128 unsigned cancel_all_awakables_call_count_ MOJO_GUARDED_BY(mutex_) = 0; | 132 unsigned cancel_all_awakables_call_count_ MOJO_GUARDED_BY(mutex_) = 0; |
| 129 | 133 |
| 130 bool add_awakable_allowed_ MOJO_GUARDED_BY(mutex_) = false; | 134 bool add_awakable_allowed_ MOJO_GUARDED_BY(mutex_) = false; |
| 131 std::vector<Awakable*> added_awakables_ MOJO_GUARDED_BY(mutex_); | 135 std::vector<Awakable*> added_awakables_ MOJO_GUARDED_BY(mutex_); |
| 132 | 136 |
| 133 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo); | 137 MOJO_DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo); |
| 134 }; | 138 }; |
| 135 | 139 |
| 136 } // namespace test | 140 } // namespace test |
| 137 } // namespace system | 141 } // namespace system |
| 138 } // namespace mojo | 142 } // namespace mojo |
| 139 | 143 |
| 140 #endif // MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ | 144 #endif // MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ |
| OLD | NEW |