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

Unified Diff: mojo/system/shared_buffer_dispatcher_unittest.cc

Issue 475223002: Mojo: Add embedder::PlatformSupport and a simple implementation (and a bit of plumbing). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: mojo/system/shared_buffer_dispatcher_unittest.cc
diff --git a/mojo/system/shared_buffer_dispatcher_unittest.cc b/mojo/system/shared_buffer_dispatcher_unittest.cc
index 9713c12ae051c8786261d7bad45fe08a1ac0527a..9ea5832f7d5fe1e5b3d62dc660dfd4465cb384d3 100644
--- a/mojo/system/shared_buffer_dispatcher_unittest.cc
+++ b/mojo/system/shared_buffer_dispatcher_unittest.cc
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "mojo/embedder/platform_shared_buffer.h"
+#include "mojo/embedder/simple_platform_support.h"
#include "mojo/system/dispatcher.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,8 +40,21 @@ void RevalidateCreateOptions(
EXPECT_EQ(validated_options.flags, revalidated_options.flags);
}
+class SharedBufferDispatcherTest : public testing::Test {
+ public:
+ SharedBufferDispatcherTest() {}
+ virtual ~SharedBufferDispatcherTest() {}
+
+ embedder::PlatformSupport* platform_support() { return &platform_support_; }
+
+ private:
+ embedder::SimplePlatformSupport platform_support_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcherTest);
+};
+
// Tests valid inputs to |ValidateCreateOptions()|.
-TEST(SharedBufferDispatcherTest, ValidateCreateOptionsValid) {
+TEST_F(SharedBufferDispatcherTest, ValidateCreateOptionsValid) {
// Default options.
{
MojoCreateSharedBufferOptions validated_options = {};
@@ -73,7 +87,7 @@ TEST(SharedBufferDispatcherTest, ValidateCreateOptionsValid) {
}
}
-TEST(SharedBufferDispatcherTest, ValidateCreateOptionsInvalid) {
+TEST_F(SharedBufferDispatcherTest, ValidateCreateOptionsInvalid) {
// Invalid |struct_size|.
{
MojoCreateSharedBufferOptions options = {
@@ -99,12 +113,14 @@ TEST(SharedBufferDispatcherTest, ValidateCreateOptionsInvalid) {
}
}
-TEST(SharedBufferDispatcherTest, CreateAndMapBuffer) {
+TEST_F(SharedBufferDispatcherTest, CreateAndMapBuffer) {
scoped_refptr<SharedBufferDispatcher> dispatcher;
- EXPECT_EQ(
- MOJO_RESULT_OK,
- SharedBufferDispatcher::Create(
- SharedBufferDispatcher::kDefaultCreateOptions, 100, &dispatcher));
+ EXPECT_EQ(MOJO_RESULT_OK,
+ SharedBufferDispatcher::Create(
+ platform_support(),
+ SharedBufferDispatcher::kDefaultCreateOptions,
+ 100,
+ &dispatcher));
ASSERT_TRUE(dispatcher);
EXPECT_EQ(Dispatcher::kTypeSharedBuffer, dispatcher->GetType());
@@ -136,12 +152,14 @@ TEST(SharedBufferDispatcherTest, CreateAndMapBuffer) {
EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[51]);
}
-TEST(SharedBufferDispatcher, DuplicateBufferHandle) {
+TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandle) {
scoped_refptr<SharedBufferDispatcher> dispatcher1;
- EXPECT_EQ(
- MOJO_RESULT_OK,
- SharedBufferDispatcher::Create(
- SharedBufferDispatcher::kDefaultCreateOptions, 100, &dispatcher1));
+ EXPECT_EQ(MOJO_RESULT_OK,
+ SharedBufferDispatcher::Create(
+ platform_support(),
+ SharedBufferDispatcher::kDefaultCreateOptions,
+ 100,
+ &dispatcher1));
// Map and write something.
scoped_ptr<embedder::PlatformSharedBufferMapping> mapping;
@@ -170,12 +188,14 @@ TEST(SharedBufferDispatcher, DuplicateBufferHandle) {
EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close());
}
-TEST(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) {
+TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) {
scoped_refptr<SharedBufferDispatcher> dispatcher1;
- EXPECT_EQ(
- MOJO_RESULT_OK,
- SharedBufferDispatcher::Create(
- SharedBufferDispatcher::kDefaultCreateOptions, 100, &dispatcher1));
+ EXPECT_EQ(MOJO_RESULT_OK,
+ SharedBufferDispatcher::Create(
+ platform_support(),
+ SharedBufferDispatcher::kDefaultCreateOptions,
+ 100,
+ &dispatcher1));
MojoDuplicateBufferHandleOptions options[] = {
{sizeof(MojoDuplicateBufferHandleOptions),
@@ -194,12 +214,14 @@ TEST(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) {
EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close());
}
-TEST(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) {
+TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) {
scoped_refptr<SharedBufferDispatcher> dispatcher1;
- EXPECT_EQ(
- MOJO_RESULT_OK,
- SharedBufferDispatcher::Create(
- SharedBufferDispatcher::kDefaultCreateOptions, 100, &dispatcher1));
+ EXPECT_EQ(MOJO_RESULT_OK,
+ SharedBufferDispatcher::Create(
+ platform_support(),
+ SharedBufferDispatcher::kDefaultCreateOptions,
+ 100,
+ &dispatcher1));
// Invalid |struct_size|.
{
@@ -226,11 +248,12 @@ TEST(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) {
EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close());
}
-TEST(SharedBufferDispatcherTest, CreateInvalidNumBytes) {
+TEST_F(SharedBufferDispatcherTest, CreateInvalidNumBytes) {
// Size too big.
scoped_refptr<SharedBufferDispatcher> dispatcher;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
SharedBufferDispatcher::Create(
+ platform_support(),
SharedBufferDispatcher::kDefaultCreateOptions,
std::numeric_limits<uint64_t>::max(),
&dispatcher));
@@ -239,16 +262,21 @@ TEST(SharedBufferDispatcherTest, CreateInvalidNumBytes) {
// Zero size.
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
SharedBufferDispatcher::Create(
- SharedBufferDispatcher::kDefaultCreateOptions, 0, &dispatcher));
+ platform_support(),
+ SharedBufferDispatcher::kDefaultCreateOptions,
+ 0,
+ &dispatcher));
EXPECT_FALSE(dispatcher);
}
-TEST(SharedBufferDispatcherTest, MapBufferInvalidArguments) {
+TEST_F(SharedBufferDispatcherTest, MapBufferInvalidArguments) {
scoped_refptr<SharedBufferDispatcher> dispatcher;
- EXPECT_EQ(
- MOJO_RESULT_OK,
- SharedBufferDispatcher::Create(
- SharedBufferDispatcher::kDefaultCreateOptions, 100, &dispatcher));
+ EXPECT_EQ(MOJO_RESULT_OK,
+ SharedBufferDispatcher::Create(
+ platform_support(),
+ SharedBufferDispatcher::kDefaultCreateOptions,
+ 100,
+ &dispatcher));
scoped_ptr<embedder::PlatformSharedBufferMapping> mapping;
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
« mojo/embedder/platform_support.h ('K') | « mojo/system/shared_buffer_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698