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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 14018018: Support Float32x4List in the embedding API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index cc2d2de3cca215149e368cd05eecbb5128c48e79..a47c70cdda9d81d0d7dd984d85ce77a31b2d2b45 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1359,6 +1359,55 @@ TEST_CASE(ExternalTypedDataCallback) {
EXPECT(peer == 42);
}
+
+static void CheckFloat32x4Data(Dart_Handle obj) {
+ void* raw_data = NULL;
+ intptr_t len;
+ Dart_TypedData_Type type;
+ EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len));
+ EXPECT_EQ(kFloat32x4, type);
+ EXPECT_EQ(len, 10);
+ float* float_data = reinterpret_cast<float*>(raw_data);
+ for (int i = 0; i < len * 4; i++) {
+ EXPECT_EQ(0.0, float_data[i]);
+ }
+ EXPECT_VALID(Dart_TypedDataReleaseData(obj));
+}
+
+
+TEST_CASE(Float32x4List) {
+ const char* kScriptChars =
+ "import 'dart:typeddata';\n"
+ "Float32x4List float32x4() {\n"
+ " return new Float32x4List(10);\n"
+ "}\n";
+ // Create a test library and Load up a test script in it.
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+
+ Dart_Handle obj = Dart_Invoke(lib, NewString("float32x4"), 0, NULL);
+ EXPECT_VALID(obj);
+ CheckFloat32x4Data(obj);
+
+ obj = Dart_NewTypedData(kFloat32x4, 10);
+ EXPECT_VALID(obj);
+ CheckFloat32x4Data(obj);
+
+ int peer = 0;
+ float data[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
+ obj = Dart_NewExternalTypedData(kFloat32x4,
+ data,
+ 10,
+ &peer,
+ ExternalTypedDataCallbackFinalizer);
+ CheckFloat32x4Data(obj);
+ Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
+ EXPECT(peer == 42);
+}
+
+
#endif
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698