| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "mojo/edk/embedder/embedder_internal.h" | 12 #include "mojo/edk/embedder/embedder_internal.h" |
| 13 #include "mojo/edk/system/test_utils.h" | 13 #include "mojo/edk/system/test_utils.h" |
| 14 #include "mojo/public/c/system/types.h" | 14 #include "mojo/public/c/system/types.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace mojo { | 17 namespace mojo { |
| 18 namespace edk { | 18 namespace edk { |
| 19 | 19 |
| 20 class Core; | 20 class Core; |
| 21 class Awakable; | |
| 22 | 21 |
| 23 namespace test { | 22 namespace test { |
| 24 | 23 |
| 25 class CoreTestBase_MockHandleInfo; | 24 class CoreTestBase_MockHandleInfo; |
| 26 | 25 |
| 27 class CoreTestBase : public testing::Test { | 26 class CoreTestBase : public testing::Test { |
| 28 public: | 27 public: |
| 29 using MockHandleInfo = CoreTestBase_MockHandleInfo; | 28 using MockHandleInfo = CoreTestBase_MockHandleInfo; |
| 30 | 29 |
| 31 CoreTestBase(); | 30 CoreTestBase(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 50 unsigned GetDtorCallCount() const; | 49 unsigned GetDtorCallCount() const; |
| 51 unsigned GetCloseCallCount() const; | 50 unsigned GetCloseCallCount() const; |
| 52 unsigned GetWriteMessageCallCount() const; | 51 unsigned GetWriteMessageCallCount() const; |
| 53 unsigned GetReadMessageCallCount() const; | 52 unsigned GetReadMessageCallCount() const; |
| 54 unsigned GetWriteDataCallCount() const; | 53 unsigned GetWriteDataCallCount() const; |
| 55 unsigned GetBeginWriteDataCallCount() const; | 54 unsigned GetBeginWriteDataCallCount() const; |
| 56 unsigned GetEndWriteDataCallCount() const; | 55 unsigned GetEndWriteDataCallCount() const; |
| 57 unsigned GetReadDataCallCount() const; | 56 unsigned GetReadDataCallCount() const; |
| 58 unsigned GetBeginReadDataCallCount() const; | 57 unsigned GetBeginReadDataCallCount() const; |
| 59 unsigned GetEndReadDataCallCount() const; | 58 unsigned GetEndReadDataCallCount() const; |
| 60 unsigned GetAddAwakableCallCount() const; | |
| 61 unsigned GetRemoveAwakableCallCount() const; | |
| 62 | |
| 63 size_t GetAddedAwakableSize() const; | |
| 64 Awakable* GetAddedAwakableAt(unsigned i) const; | |
| 65 | 59 |
| 66 // For use by |MockDispatcher|: | 60 // For use by |MockDispatcher|: |
| 67 void IncrementCtorCallCount(); | 61 void IncrementCtorCallCount(); |
| 68 void IncrementDtorCallCount(); | 62 void IncrementDtorCallCount(); |
| 69 void IncrementCloseCallCount(); | 63 void IncrementCloseCallCount(); |
| 70 void IncrementWriteMessageCallCount(); | 64 void IncrementWriteMessageCallCount(); |
| 71 void IncrementReadMessageCallCount(); | 65 void IncrementReadMessageCallCount(); |
| 72 void IncrementWriteDataCallCount(); | 66 void IncrementWriteDataCallCount(); |
| 73 void IncrementBeginWriteDataCallCount(); | 67 void IncrementBeginWriteDataCallCount(); |
| 74 void IncrementEndWriteDataCallCount(); | 68 void IncrementEndWriteDataCallCount(); |
| 75 void IncrementReadDataCallCount(); | 69 void IncrementReadDataCallCount(); |
| 76 void IncrementBeginReadDataCallCount(); | 70 void IncrementBeginReadDataCallCount(); |
| 77 void IncrementEndReadDataCallCount(); | 71 void IncrementEndReadDataCallCount(); |
| 78 void IncrementAddAwakableCallCount(); | |
| 79 void IncrementRemoveAwakableCallCount(); | |
| 80 | |
| 81 void AllowAddAwakable(bool alllow); | |
| 82 bool IsAddAwakableAllowed() const; | |
| 83 void AwakableWasAdded(Awakable*); | |
| 84 | 72 |
| 85 private: | 73 private: |
| 86 mutable base::Lock lock_; // Protects the following members. | 74 mutable base::Lock lock_; // Protects the following members. |
| 87 unsigned ctor_call_count_; | 75 unsigned ctor_call_count_; |
| 88 unsigned dtor_call_count_; | 76 unsigned dtor_call_count_; |
| 89 unsigned close_call_count_; | 77 unsigned close_call_count_; |
| 90 unsigned write_message_call_count_; | 78 unsigned write_message_call_count_; |
| 91 unsigned read_message_call_count_; | 79 unsigned read_message_call_count_; |
| 92 unsigned write_data_call_count_; | 80 unsigned write_data_call_count_; |
| 93 unsigned begin_write_data_call_count_; | 81 unsigned begin_write_data_call_count_; |
| 94 unsigned end_write_data_call_count_; | 82 unsigned end_write_data_call_count_; |
| 95 unsigned read_data_call_count_; | 83 unsigned read_data_call_count_; |
| 96 unsigned begin_read_data_call_count_; | 84 unsigned begin_read_data_call_count_; |
| 97 unsigned end_read_data_call_count_; | 85 unsigned end_read_data_call_count_; |
| 98 unsigned add_awakable_call_count_; | |
| 99 unsigned remove_awakable_call_count_; | |
| 100 | |
| 101 bool add_awakable_allowed_; | |
| 102 std::vector<Awakable*> added_awakables_; | |
| 103 | 86 |
| 104 DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo); | 87 DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo); |
| 105 }; | 88 }; |
| 106 | 89 |
| 107 } // namespace test | 90 } // namespace test |
| 108 } // namespace edk | 91 } // namespace edk |
| 109 } // namespace mojo | 92 } // namespace mojo |
| 110 | 93 |
| 111 #endif // MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ | 94 #endif // MOJO_EDK_SYSTEM_CORE_TEST_BASE_H_ |
| OLD | NEW |