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

Unified Diff: third_party/mojo/src/mojo/public/cpp/bindings/tests/union_unittest.cc

Issue 1430913005: Revert of Change mojo_public_bindings_unittests to use chromium environment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: third_party/mojo/src/mojo/public/cpp/bindings/tests/union_unittest.cc
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/tests/union_unittest.cc b/third_party/mojo/src/mojo/public/cpp/bindings/tests/union_unittest.cc
index e6fddb783c7ecd1885921e7a257a739989a092ae..e008b7497095c0cfdb09303bd8ce16d78051ba1c 100644
--- a/third_party/mojo/src/mojo/public/cpp/bindings/tests/union_unittest.cc
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/tests/union_unittest.cc
@@ -3,9 +3,6 @@
// found in the LICENSE file.
#include <vector>
-
-#include "base/message_loop/message_loop.h"
-#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/lib/array_internal.h"
@@ -13,7 +10,9 @@
#include "mojo/public/cpp/bindings/lib/bounds_checker.h"
#include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
#include "mojo/public/cpp/bindings/string.h"
+#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/test_support/test_utils.h"
+#include "mojo/public/cpp/utility/run_loop.h"
#include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
#include "mojo/public/interfaces/bindings/tests/test_unions.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -221,6 +220,7 @@
}
TEST(UnionTest, OutOfAlignmentValidation) {
+ Environment environment;
size_t size = sizeof(internal::PodUnion_Data);
// Get an aligned object and shift the alignment.
mojo::internal::FixedBufferForTesting aligned_buf(size + 1);
@@ -236,6 +236,7 @@
}
TEST(UnionTest, OOBValidation) {
+ Environment environment;
size_t size = sizeof(internal::PodUnion_Data) - 1;
mojo::internal::FixedBufferForTesting buf(size);
internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf);
@@ -248,6 +249,7 @@
}
TEST(UnionTest, UnknownTagValidation) {
+ Environment environment;
size_t size = sizeof(internal::PodUnion_Data);
mojo::internal::FixedBufferForTesting buf(size);
internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf);
@@ -316,6 +318,7 @@
}
TEST(UnionTest, NullStringValidation) {
+ Environment environment;
size_t size = sizeof(internal::ObjectUnion_Data);
mojo::internal::FixedBufferForTesting buf(size);
internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf);
@@ -330,6 +333,7 @@
}
TEST(UnionTest, StringPointerOverflowValidation) {
+ Environment environment;
size_t size = sizeof(internal::ObjectUnion_Data);
mojo::internal::FixedBufferForTesting buf(size);
internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf);
@@ -344,6 +348,7 @@
}
TEST(UnionTest, StringValidateOOB) {
+ Environment environment;
size_t size = 32;
mojo::internal::FixedBufferForTesting buf(size);
internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf);
@@ -378,6 +383,7 @@
}
TEST(UnionTest, PodUnionInArraySerialization) {
+ Environment environment;
Array<PodUnionPtr> array(2);
array[0] = PodUnion::New();
array[1] = PodUnion::New();
@@ -404,6 +410,7 @@
}
TEST(UnionTest, PodUnionInArraySerializationWithNull) {
+ Environment environment;
Array<PodUnionPtr> array(2);
array[0] = PodUnion::New();
@@ -430,6 +437,7 @@
// TODO(azani): Move back in struct_unittest.cc when possible.
// Struct tests
TEST(UnionTest, Clone_Union) {
+ Environment environment;
SmallStructPtr small_struct(SmallStruct::New());
small_struct->pod_union = PodUnion::New();
small_struct->pod_union->set_f_int8(10);
@@ -440,6 +448,7 @@
// Serialization test of a struct with a union of plain old data.
TEST(UnionTest, Serialization_UnionOfPods) {
+ Environment environment;
SmallStructPtr small_struct(SmallStruct::New());
small_struct->pod_union = PodUnion::New();
small_struct->pod_union->set_f_int32(10);
@@ -458,6 +467,7 @@
// Serialization test of a struct with a union of structs.
TEST(UnionTest, Serialization_UnionOfObjects) {
+ Environment environment;
SmallObjStructPtr obj_struct(SmallObjStruct::New());
obj_struct->obj_union = ObjectUnion::New();
String hello("hello world");
@@ -481,6 +491,7 @@
// Validation test of a struct with a union.
TEST(UnionTest, Validation_UnionsInStruct) {
+ Environment environment;
SmallStructPtr small_struct(SmallStruct::New());
small_struct->pod_union = PodUnion::New();
small_struct->pod_union->set_f_int32(10);
@@ -504,6 +515,7 @@
// Validation test of a struct union fails due to unknown union tag.
TEST(UnionTest, Validation_PodUnionInStruct_Failure) {
+ Environment environment;
SmallStructPtr small_struct(SmallStruct::New());
small_struct->pod_union = PodUnion::New();
small_struct->pod_union->set_f_int32(10);
@@ -528,6 +540,7 @@
// Validation fails due to non-nullable null union in struct.
TEST(UnionTest, Validation_NullUnion_Failure) {
+ Environment environment;
SmallStructNonNullableUnionPtr small_struct(
SmallStructNonNullableUnion::New());
@@ -547,6 +560,7 @@
// Validation passes with nullable null union.
TEST(UnionTest, Validation_NullableUnion) {
+ Environment environment;
SmallStructPtr small_struct(SmallStruct::New());
size_t size = GetSerializedSize_(small_struct);
@@ -582,6 +596,7 @@
}
TEST(UnionTest, PodUnionInMapSerialization) {
+ Environment environment;
Map<String, PodUnionPtr> map;
map.insert("one", PodUnion::New());
map.insert("two", PodUnion::New());
@@ -606,6 +621,7 @@
}
TEST(UnionTest, PodUnionInMapSerializationWithNull) {
+ Environment environment;
Map<String, PodUnionPtr> map;
map.insert("one", PodUnion::New());
map.insert("two", nullptr);
@@ -639,6 +655,7 @@
}
TEST(UnionTest, StructInUnionSerialization) {
+ Environment environment;
DummyStructPtr dummy(DummyStruct::New());
dummy->f_int8 = 8;
@@ -662,6 +679,7 @@
}
TEST(UnionTest, StructInUnionValidation) {
+ Environment environment;
DummyStructPtr dummy(DummyStruct::New());
dummy->f_int8 = 8;
@@ -687,6 +705,7 @@
}
TEST(UnionTest, StructInUnionValidationNonNullable) {
+ Environment environment;
DummyStructPtr dummy(nullptr);
ObjectUnionPtr obj(ObjectUnion::New());
@@ -711,6 +730,7 @@
}
TEST(UnionTest, StructInUnionValidationNullable) {
+ Environment environment;
DummyStructPtr dummy(nullptr);
ObjectUnionPtr obj(ObjectUnion::New());
@@ -735,6 +755,8 @@
}
TEST(UnionTest, ArrayInUnionGetterSetter) {
+ Environment environment;
+
Array<int8_t> array(2);
array[0] = 8;
array[1] = 9;
@@ -747,6 +769,8 @@
}
TEST(UnionTest, ArrayInUnionSerialization) {
+ Environment environment;
+
Array<int8_t> array(2);
array[0] = 8;
array[1] = 9;
@@ -773,6 +797,8 @@
}
TEST(UnionTest, ArrayInUnionValidation) {
+ Environment environment;
+
Array<int8_t> array(2);
array[0] = 8;
array[1] = 9;
@@ -798,6 +824,7 @@
}
TEST(UnionTest, MapInUnionGetterSetter) {
+ Environment environment;
Map<String, int8_t> map;
map.insert("one", 1);
map.insert("two", 2);
@@ -810,6 +837,7 @@
}
TEST(UnionTest, MapInUnionSerialization) {
+ Environment environment;
Map<String, int8_t> map;
map.insert("one", 1);
map.insert("two", 2);
@@ -836,6 +864,7 @@
}
TEST(UnionTest, MapInUnionValidation) {
+ Environment environment;
Map<String, int8_t> map;
map.insert("one", 1);
map.insert("two", 2);
@@ -874,6 +903,7 @@
}
TEST(UnionTest, UnionInUnionSerialization) {
+ Environment environment;
PodUnionPtr pod(PodUnion::New());
pod->set_f_int8(10);
@@ -897,6 +927,7 @@
}
TEST(UnionTest, UnionInUnionValidation) {
+ Environment environment;
PodUnionPtr pod(PodUnion::New());
pod->set_f_int8(10);
@@ -923,6 +954,7 @@
}
TEST(UnionTest, UnionInUnionValidationNonNullable) {
+ Environment environment;
PodUnionPtr pod(nullptr);
ObjectUnionPtr obj(ObjectUnion::New());
@@ -996,6 +1028,7 @@
}
TEST(UnionTest, HandleInUnionValidation) {
+ Environment environment;
ScopedMessagePipeHandle pipe0;
ScopedMessagePipeHandle pipe1;
@@ -1023,6 +1056,7 @@
}
TEST(UnionTest, HandleInUnionValidationNull) {
+ Environment environment;
ScopedMessagePipeHandle pipe;
HandleUnionPtr handle(HandleUnion::New());
handle->set_f_message_pipe(pipe.Pass());
@@ -1061,7 +1095,8 @@
};
TEST(UnionTest, InterfaceInUnion) {
- base::MessageLoop run_loop(common::MessagePumpMojo::Create());
+ Environment env;
+ RunLoop run_loop;
SmallCacheImpl impl;
SmallCachePtr ptr;
Binding<SmallCache> bindings(&impl, GetProxy(&ptr));
@@ -1075,7 +1110,8 @@
}
TEST(UnionTest, InterfaceInUnionSerialization) {
- base::MessageLoop run_loop(common::MessagePumpMojo::Create());
+ Environment env;
+ RunLoop run_loop;
SmallCacheImpl impl;
SmallCachePtr ptr;
Binding<SmallCache> bindings(&impl, GetProxy(&ptr));
@@ -1114,7 +1150,8 @@
};
TEST(UnionTest, UnionInInterface) {
- base::MessageLoop run_loop(common::MessagePumpMojo::Create());
+ Environment env;
+ RunLoop run_loop;
UnionInterfaceImpl impl;
UnionInterfacePtr ptr;
Binding<UnionInterface> bindings(&impl, GetProxy(&ptr));

Powered by Google App Engine
This is Rietveld 408576698