diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-27 22:37:25 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-27 22:37:25 +0000 |
commit | 31b6194e4539ebd15a0bae31ca310badd23c5527 (patch) | |
tree | 1e35bfd404fe06530163baa88fa8aaecfdf51f7f /mojo/system/core_test_base.h | |
parent | aea757d730546d961dcdb414b806d5548a2d88ea (diff) | |
download | chromium_src-31b6194e4539ebd15a0bae31ca310badd23c5527.zip chromium_src-31b6194e4539ebd15a0bae31ca310badd23c5527.tar.gz chromium_src-31b6194e4539ebd15a0bae31ca310badd23c5527.tar.bz2 |
Initial in-process implementation of some Mojo primitives.
This has an initial in-process implementation of the most basic Mojo primitives:
- MojoClose()
- MojoWait()
- MojoWaitMany()
- MojoCreateMessagePipe()
- MojoWriteMessage()
- MojoReadMessage()
R=darin@chromium.org
Review URL: https://codereview.chromium.org/23621056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system/core_test_base.h')
-rw-r--r-- | mojo/system/core_test_base.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/mojo/system/core_test_base.h b/mojo/system/core_test_base.h new file mode 100644 index 0000000..114e62e --- /dev/null +++ b/mojo/system/core_test_base.h @@ -0,0 +1,87 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_SYSTEM_CORE_TEST_BASE_H_ +#define MOJO_SYSTEM_CORE_TEST_BASE_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/synchronization/lock.h" +#include "mojo/public/system/core.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace mojo { +namespace system { + +class CoreImpl; + +namespace test { + +class CoreTestBase_MockHandleInfo; + +class CoreTestBase : public testing::Test { + public: + typedef CoreTestBase_MockHandleInfo MockHandleInfo; + + CoreTestBase(); + virtual ~CoreTestBase(); + + virtual void SetUp() OVERRIDE; + virtual void TearDown() OVERRIDE; + + protected: + // |info| must remain alive until the returned handle is closed. + MojoHandle CreateMockHandle(MockHandleInfo* info); + + CoreImpl* core() { return core_; } + + private: + CoreImpl* core_; + + DISALLOW_COPY_AND_ASSIGN(CoreTestBase); +}; + +class CoreTestBase_MockHandleInfo { + public: + CoreTestBase_MockHandleInfo(); + ~CoreTestBase_MockHandleInfo(); + + unsigned GetCtorCallCount() const; + unsigned GetDtorCallCount() const; + unsigned GetCloseCallCount() const; + unsigned GetWriteMessageCallCount() const; + unsigned GetReadMessageCallCount() const; + unsigned GetAddWaiterCallCount() const; + unsigned GetRemoveWaiterCallCount() const; + unsigned GetCancelAllWaitersCallCount() const; + + // For use by |MockDispatcher|: + void IncrementCtorCallCount(); + void IncrementDtorCallCount(); + void IncrementCloseCallCount(); + void IncrementWriteMessageCallCount(); + void IncrementReadMessageCallCount(); + void IncrementAddWaiterCallCount(); + void IncrementRemoveWaiterCallCount(); + void IncrementCancelAllWaitersCallCount(); + + private: + mutable base::Lock lock_; // Protects the following members. + unsigned ctor_call_count_; + unsigned dtor_call_count_; + unsigned close_call_count_; + unsigned write_message_call_count_; + unsigned read_message_call_count_; + unsigned add_waiter_call_count_; + unsigned remove_waiter_call_count_; + unsigned cancel_all_waiters_call_count_; + + DISALLOW_COPY_AND_ASSIGN(CoreTestBase_MockHandleInfo); +}; + +} // namespace test +} // namespace system +} // namespace mojo + +#endif // MOJO_SYSTEM_CORE_TEST_BASE_H_ |