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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 392043003: The dart version of typeddata library has changed to be compatible with the dart2js implementation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 38347)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -1429,6 +1429,9 @@
EXPECT_EQ(Dart_TypedData_kInvalid,
Dart_GetTypeOfExternalTypedData(byte_array1));
EXPECT(Dart_IsList(byte_array1));
+ EXPECT(!Dart_IsTypedData(Dart_True()));
+ EXPECT(Dart_IsTypedData(byte_array1));
+ EXPECT(!Dart_IsByteBuffer(byte_array1));
intptr_t length = 0;
Dart_Handle result = Dart_ListLength(byte_array1, &length);
@@ -1490,6 +1493,50 @@
}
+TEST_CASE(ByteBufferAccess) {
+ EXPECT(!Dart_IsByteBuffer(Dart_True()));
+ Dart_Handle byte_array = Dart_NewTypedData(Dart_TypedData_kUint8, 10);
+ EXPECT_VALID(byte_array);
+ // Set through the List API.
+ for (intptr_t i = 0; i < 10; ++i) {
+ EXPECT_VALID(Dart_ListSetAt(byte_array, i, Dart_NewInteger(i + 1)));
+ }
+ Dart_Handle byte_buffer = Dart_NewByteBuffer(byte_array);
+ EXPECT_VALID(byte_buffer);
+ EXPECT(Dart_IsByteBuffer(byte_buffer));
+ EXPECT(!Dart_IsTypedData(byte_buffer));
+
+ Dart_Handle byte_buffer_data = Dart_GetDataFromByteBuffer(byte_buffer);
+ EXPECT_VALID(byte_buffer_data);
+ EXPECT(!Dart_IsByteBuffer(byte_buffer_data));
+ EXPECT(Dart_IsTypedData(byte_buffer_data));
+
+ intptr_t length = 0;
+ Dart_Handle result = Dart_ListLength(byte_buffer_data, &length);
+ EXPECT_VALID(result);
+ EXPECT_EQ(10, length);
+
+ for (intptr_t i = 0; i < 10; ++i) {
+ // Get through the List API.
+ Dart_Handle integer_obj = Dart_ListGetAt(byte_buffer_data, i);
+ EXPECT_VALID(integer_obj);
+ int64_t int64_t_value = -1;
+ EXPECT_VALID(Dart_IntegerToInt64(integer_obj, &int64_t_value));
+ EXPECT_EQ(i + 1, int64_t_value);
+ }
+
+ // Some negative tests.
+ result = Dart_NewByteBuffer(Dart_True());
+ EXPECT(Dart_IsError(result));
+ result = Dart_NewByteBuffer(byte_buffer);
+ EXPECT(Dart_IsError(result));
+ result = Dart_GetDataFromByteBuffer(Dart_False());
+ EXPECT(Dart_IsError(result));
+ result = Dart_GetDataFromByteBuffer(byte_array);
+ EXPECT(Dart_IsError(result));
+}
+
+
static int kLength = 16;
static void ByteDataNativeFunction(Dart_NativeArguments args) {
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698