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