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

Unified Diff: mojo/edk/system/options_validation_unittest.cc

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup Created 5 years, 3 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/edk/system/options_validation_unittest.cc
diff --git a/third_party/mojo/src/mojo/edk/system/options_validation_unittest.cc b/mojo/edk/system/options_validation_unittest.cc
similarity index 85%
copy from third_party/mojo/src/mojo/edk/system/options_validation_unittest.cc
copy to mojo/edk/system/options_validation_unittest.cc
index dab6597558dbe0711d104c00ef59c320c2a44dbf..d2c81808dae597aa8ea8ef7805f8817baa1b7358 100644
--- a/third_party/mojo/src/mojo/edk/system/options_validation_unittest.cc
+++ b/mojo/edk/system/options_validation_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "third_party/mojo/src/mojo/edk/system/options_validation.h"
+#include "mojo/edk/system/options_validation.h"
#include <stddef.h>
#include <stdint.h>
@@ -11,7 +11,7 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
-namespace system {
+namespace edk {
namespace {
// Declare a test options struct just as we do in actual public headers.
@@ -32,7 +32,7 @@ const uint32_t kSizeOfTestOptions = static_cast<uint32_t>(sizeof(TestOptions));
TEST(OptionsValidationTest, Valid) {
{
const TestOptions kOptions = {kSizeOfTestOptions};
- UserOptionsReader<TestOptions> reader(MakeUserPointer(&kOptions));
+ UserOptionsReader<TestOptions> reader(&kOptions);
EXPECT_TRUE(reader.is_valid());
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, flags, reader));
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, member1, reader));
@@ -41,7 +41,7 @@ TEST(OptionsValidationTest, Valid) {
{
const TestOptions kOptions = {static_cast<uint32_t>(
offsetof(TestOptions, struct_size) + sizeof(uint32_t))};
- UserOptionsReader<TestOptions> reader(MakeUserPointer(&kOptions));
+ UserOptionsReader<TestOptions> reader(&kOptions);
EXPECT_TRUE(reader.is_valid());
EXPECT_FALSE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, flags, reader));
EXPECT_FALSE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, member1, reader));
@@ -51,7 +51,7 @@ TEST(OptionsValidationTest, Valid) {
{
const TestOptions kOptions = {
static_cast<uint32_t>(offsetof(TestOptions, flags) + sizeof(uint32_t))};
- UserOptionsReader<TestOptions> reader(MakeUserPointer(&kOptions));
+ UserOptionsReader<TestOptions> reader(&kOptions);
EXPECT_TRUE(reader.is_valid());
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, flags, reader));
EXPECT_FALSE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, member1, reader));
@@ -61,7 +61,7 @@ TEST(OptionsValidationTest, Valid) {
MOJO_ALIGNAS(8) char buf[sizeof(TestOptions) + 100] = {};
TestOptions* options = reinterpret_cast<TestOptions*>(buf);
options->struct_size = kSizeOfTestOptions + 1;
- UserOptionsReader<TestOptions> reader(MakeUserPointer(options));
+ UserOptionsReader<TestOptions> reader(options);
EXPECT_TRUE(reader.is_valid());
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, flags, reader));
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, member1, reader));
@@ -71,7 +71,7 @@ TEST(OptionsValidationTest, Valid) {
MOJO_ALIGNAS(8) char buf[sizeof(TestOptions) + 100] = {};
TestOptions* options = reinterpret_cast<TestOptions*>(buf);
options->struct_size = kSizeOfTestOptions + 4;
- UserOptionsReader<TestOptions> reader(MakeUserPointer(options));
+ UserOptionsReader<TestOptions> reader(options);
EXPECT_TRUE(reader.is_valid());
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, flags, reader));
EXPECT_TRUE(OPTIONS_STRUCT_HAS_MEMBER(TestOptions, member1, reader));
@@ -83,7 +83,7 @@ TEST(OptionsValidationTest, Invalid) {
// Size too small:
for (size_t i = 0; i < sizeof(uint32_t); i++) {
TestOptions options = {static_cast<uint32_t>(i)};
- UserOptionsReader<TestOptions> reader(MakeUserPointer(&options));
+ UserOptionsReader<TestOptions> reader(&options);
EXPECT_FALSE(reader.is_valid()) << i;
}
}
@@ -99,14 +99,14 @@ TEST(OptionsValidationTest, InvalidDeath) {
// Null:
EXPECT_DEATH_IF_SUPPORTED(
- { UserOptionsReader<TestOptions> reader((NullUserPointer())); },
+ { UserOptionsReader<TestOptions> reader((nullptr)); },
kMemoryCheckFailedRegex);
// Unaligned:
EXPECT_DEATH_IF_SUPPORTED(
{
UserOptionsReader<TestOptions> reader(
- MakeUserPointer(reinterpret_cast<const TestOptions*>(1)));
+ reinterpret_cast<const TestOptions*>(1));
},
kMemoryCheckFailedRegex);
// Note: The current implementation checks the size only after checking the
@@ -120,11 +120,11 @@ TEST(OptionsValidationTest, InvalidDeath) {
? reinterpret_cast<TestOptions*>(&buffer[1])
: reinterpret_cast<TestOptions*>(&buffer[0]);
options->struct_size = static_cast<uint32_t>(sizeof(TestOptions));
- UserOptionsReader<TestOptions> reader(MakeUserPointer(options));
+ UserOptionsReader<TestOptions> reader(options);
},
kMemoryCheckFailedRegex);
}
} // namespace
-} // namespace system
+} // namespace edk
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698