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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1156993012: Fix for issue 23547, return an proper ApiError instead of a string when we report outstanding typed… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | runtime/vm/dart_api_state.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
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 78d12cf437ed1c9e9345e2a39378febfc0ce36ed..e7717f80a5d42e4e85e7eeb766d3667113be592c 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1871,7 +1871,8 @@ TEST_CASE(TypedDataDirectAccessVerified) {
static void TestDirectAccess(Dart_Handle lib,
Dart_Handle array,
- Dart_TypedData_Type expected_type) {
+ Dart_TypedData_Type expected_type,
+ bool is_external) {
Dart_Handle result;
// Invoke the dart function that sets initial values.
@@ -1894,6 +1895,15 @@ static void TestDirectAccess(Dart_Handle lib,
EXPECT_EQ(i, dataP[i]);
}
+ if (!is_external) {
+ // Now try allocating a string with outstanding Acquires and it should
+ // return an error.
+ result = NewString("We expect an error here");
+ EXPECT_ERROR(result,
+ "Internal Dart data pointers have been acquired, "
+ "please release them using Dart_TypedDataReleaseData.");
+ }
+
// Now modify the values in the directly accessible array and then check
// it we see the changes back in dart.
for (int i = 0; i < kLength; i++) {
@@ -1942,7 +1952,7 @@ static void TestTypedDataDirectAccess1() {
Dart_Handle list_access_test_obj;
list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL);
EXPECT_VALID(list_access_test_obj);
- TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kInt8);
+ TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kInt8, false);
// Test with an external typed data object.
uint8_t data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -1951,7 +1961,7 @@ static void TestTypedDataDirectAccess1() {
ext_list_access_test_obj = Dart_NewExternalTypedData(Dart_TypedData_kUint8,
data, data_length);
EXPECT_VALID(ext_list_access_test_obj);
- TestDirectAccess(lib, ext_list_access_test_obj, Dart_TypedData_kUint8);
+ TestDirectAccess(lib, ext_list_access_test_obj, Dart_TypedData_kUint8, true);
}
@@ -2002,7 +2012,7 @@ static void TestTypedDataViewDirectAccess() {
Dart_Handle list_access_test_obj;
list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL);
EXPECT_VALID(list_access_test_obj);
- TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kInt8);
+ TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kInt8, false);
}
@@ -2053,7 +2063,7 @@ static void TestByteDataDirectAccess() {
Dart_Handle list_access_test_obj;
list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL);
EXPECT_VALID(list_access_test_obj);
- TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kByteData);
+ TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kByteData, false);
}
« no previous file with comments | « no previous file | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698