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

Side by Side Diff: content/child/v8_value_converter_impl_unittest.cc

Issue 2799093006: Remove base::BinaryValue (Closed)
Patch Set: Rebase Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/child/v8_value_converter_impl.h" 5 #include "content/child/v8_value_converter_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1141
1142 const char kExampleData[] = {1, 2, 3, 4, 5}; 1142 const char kExampleData[] = {1, 2, 3, 4, 5};
1143 v8::Local<v8::ArrayBuffer> array_buffer( 1143 v8::Local<v8::ArrayBuffer> array_buffer(
1144 v8::ArrayBuffer::New(isolate_, sizeof(kExampleData))); 1144 v8::ArrayBuffer::New(isolate_, sizeof(kExampleData)));
1145 memcpy(array_buffer->GetContents().Data(), kExampleData, 1145 memcpy(array_buffer->GetContents().Data(), kExampleData,
1146 sizeof(kExampleData)); 1146 sizeof(kExampleData));
1147 std::unique_ptr<base::Value> binary_value( 1147 std::unique_ptr<base::Value> binary_value(
1148 converter.FromV8Value(array_buffer, context)); 1148 converter.FromV8Value(array_buffer, context));
1149 ASSERT_TRUE(binary_value); 1149 ASSERT_TRUE(binary_value);
1150 std::unique_ptr<base::Value> reference_binary_value( 1150 std::unique_ptr<base::Value> reference_binary_value(
1151 base::BinaryValue::CreateWithCopiedBuffer(kExampleData, 1151 base::Value::CreateWithCopiedBuffer(kExampleData, sizeof(kExampleData)));
1152 sizeof(kExampleData)));
1153 EXPECT_TRUE( 1152 EXPECT_TRUE(
1154 base::Value::Equals(reference_binary_value.get(), binary_value.get())); 1153 base::Value::Equals(reference_binary_value.get(), binary_value.get()));
1155 1154
1156 v8::Local<v8::ArrayBufferView> array_buffer_view( 1155 v8::Local<v8::ArrayBufferView> array_buffer_view(
1157 v8::Uint8Array::New(array_buffer, 1, 3)); 1156 v8::Uint8Array::New(array_buffer, 1, 3));
1158 std::unique_ptr<base::Value> binary_view_value( 1157 std::unique_ptr<base::Value> binary_view_value(
1159 converter.FromV8Value(array_buffer_view, context)); 1158 converter.FromV8Value(array_buffer_view, context));
1160 ASSERT_TRUE(binary_view_value); 1159 ASSERT_TRUE(binary_view_value);
1161 std::unique_ptr<base::Value> reference_binary_view_value( 1160 std::unique_ptr<base::Value> reference_binary_view_value(
1162 base::BinaryValue::CreateWithCopiedBuffer(&kExampleData[1], 3)); 1161 base::Value::CreateWithCopiedBuffer(&kExampleData[1], 3));
1163 EXPECT_TRUE(base::Value::Equals(reference_binary_view_value.get(), 1162 EXPECT_TRUE(base::Value::Equals(reference_binary_view_value.get(),
1164 binary_view_value.get())); 1163 binary_view_value.get()));
1165 1164
1166 v8::Local<v8::Number> number(v8::Number::New(isolate_, 0.0)); 1165 v8::Local<v8::Number> number(v8::Number::New(isolate_, 0.0));
1167 std::unique_ptr<base::Value> number_value( 1166 std::unique_ptr<base::Value> number_value(
1168 converter.FromV8Value(number, context)); 1167 converter.FromV8Value(number, context));
1169 ASSERT_TRUE(number_value); 1168 ASSERT_TRUE(number_value);
1170 std::unique_ptr<base::Value> reference_number_value( 1169 std::unique_ptr<base::Value> reference_number_value(
1171 base::test::ParseJson("0")); 1170 base::test::ParseJson("0"));
1172 EXPECT_TRUE( 1171 EXPECT_TRUE(
1173 base::Value::Equals(reference_number_value.get(), number_value.get())); 1172 base::Value::Equals(reference_number_value.get(), number_value.get()));
1174 1173
1175 v8::Local<v8::Primitive> undefined(v8::Undefined(isolate_)); 1174 v8::Local<v8::Primitive> undefined(v8::Undefined(isolate_));
1176 std::unique_ptr<base::Value> undefined_value( 1175 std::unique_ptr<base::Value> undefined_value(
1177 converter.FromV8Value(undefined, context)); 1176 converter.FromV8Value(undefined, context));
1178 EXPECT_FALSE(undefined_value); 1177 EXPECT_FALSE(undefined_value);
1179 } 1178 }
1180 1179
1181 } // namespace content 1180 } // namespace content
OLDNEW
« no previous file with comments | « content/child/v8_value_converter_impl.cc ('k') | content/common/android/gin_java_bridge_value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698