OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "content/common/android/gin_java_bridge_value.h" | 12 #include "content/common/android/gin_java_bridge_value.h" |
13 #include "content/renderer/java/gin_java_bridge_value_converter.h" | 13 #include "content/renderer/java/gin_java_bridge_value_converter.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class GinJavaBridgeValueConverterTest : public testing::Test { | 20 class GinJavaBridgeValueConverterTest : public testing::Test { |
20 public: | 21 public: |
21 GinJavaBridgeValueConverterTest() | 22 GinJavaBridgeValueConverterTest() |
22 : isolate_(v8::Isolate::GetCurrent()) { | 23 : isolate_(v8::Isolate::GetCurrent()) { |
23 } | 24 } |
24 | 25 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 GinJavaBridgeValue::FromValue(undefined.get())); | 93 GinJavaBridgeValue::FromValue(undefined.get())); |
93 ASSERT_TRUE(undefined_value.get()); | 94 ASSERT_TRUE(undefined_value.get()); |
94 EXPECT_TRUE(undefined_value->IsType(GinJavaBridgeValue::TYPE_UNDEFINED)); | 95 EXPECT_TRUE(undefined_value->IsType(GinJavaBridgeValue::TYPE_UNDEFINED)); |
95 } | 96 } |
96 | 97 |
97 TEST_F(GinJavaBridgeValueConverterTest, TypedArrays) { | 98 TEST_F(GinJavaBridgeValueConverterTest, TypedArrays) { |
98 v8::HandleScope handle_scope(isolate_); | 99 v8::HandleScope handle_scope(isolate_); |
99 v8::Local<v8::Context> context = | 100 v8::Local<v8::Context> context = |
100 v8::Local<v8::Context>::New(isolate_, context_); | 101 v8::Local<v8::Context>::New(isolate_, context_); |
101 v8::Context::Scope context_scope(context); | 102 v8::Context::Scope context_scope(context); |
| 103 blink::WebScopedMicrotaskSuppression microtasks_scope; |
102 | 104 |
103 scoped_ptr<GinJavaBridgeValueConverter> converter( | 105 scoped_ptr<GinJavaBridgeValueConverter> converter( |
104 new GinJavaBridgeValueConverter()); | 106 new GinJavaBridgeValueConverter()); |
105 | 107 |
106 const char* source_template = "(function() {" | 108 const char* source_template = "(function() {" |
107 "var array_buffer = new ArrayBuffer(%s);" | 109 "var array_buffer = new ArrayBuffer(%s);" |
108 "var array_view = new %s(array_buffer);" | 110 "var array_view = new %s(array_buffer);" |
109 "array_view[0] = 42;" | 111 "array_view[0] = 42;" |
110 "return array_view;" | 112 "return array_view;" |
111 "})();"; | 113 "})();"; |
(...skipping 17 matching lines...) Expand all Loading... |
129 base::ListValue* list; | 131 base::ListValue* list; |
130 ASSERT_TRUE(list_value->GetAsList(&list)) << typed_array_type; | 132 ASSERT_TRUE(list_value->GetAsList(&list)) << typed_array_type; |
131 EXPECT_EQ(1u, list->GetSize()) << typed_array_type; | 133 EXPECT_EQ(1u, list->GetSize()) << typed_array_type; |
132 double first_element; | 134 double first_element; |
133 ASSERT_TRUE(list->GetDouble(0, &first_element)) << typed_array_type; | 135 ASSERT_TRUE(list->GetDouble(0, &first_element)) << typed_array_type; |
134 EXPECT_EQ(42.0, first_element) << typed_array_type; | 136 EXPECT_EQ(42.0, first_element) << typed_array_type; |
135 } | 137 } |
136 } | 138 } |
137 | 139 |
138 } // namespace content | 140 } // namespace content |
OLD | NEW |