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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 47293002: Add Dart_LibraryId method unblocking landing 45613003. TBR (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Ready to review Created 7 years, 2 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
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 93b658fe576412e5acf8b13fdb3b59d1625e6f7e..63ea3a10014380cd50ba0025f9847da81123e9c2 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -4,6 +4,7 @@
#include "bin/builtin.h"
#include "include/dart_api.h"
+#include "include/dart_debugger_api.h"
#include "include/dart_mirrors_api.h"
#include "include/dart_native_api.h"
#include "platform/assert.h"
@@ -4840,6 +4841,42 @@ TEST_CASE(LibraryName) {
EXPECT_STREQ("library1_name", cstr);
}
+TEST_CASE(LibraryId) {
+ const char* kLibrary1Chars =
+ "library library1_name;";
+ Dart_Handle url = NewString("library1_url");
+ Dart_Handle source = NewString(kLibrary1Chars);
+ Dart_Handle lib = Dart_LoadLibrary(url, source);
+ Dart_Handle error = Dart_NewApiError("incoming error");
+ EXPECT_VALID(lib);
+ intptr_t libraryId = -1;
+
+ Dart_Handle result = Dart_LibraryId(Dart_Null(), &libraryId);
+ EXPECT(Dart_IsError(result));
+ EXPECT_STREQ("Dart_LibraryId expects argument 'library' to be non-null.",
+ Dart_GetError(result));
+
+ result = Dart_LibraryId(Dart_True(), &libraryId);
+ EXPECT(Dart_IsError(result));
+ EXPECT_STREQ(
+ "Dart_LibraryId expects argument 'library' to be of type Library.",
+ Dart_GetError(result));
+
+ result = Dart_LibraryId(error, &libraryId);
+ EXPECT(Dart_IsError(result));
+ EXPECT_STREQ("incoming error", Dart_GetError(result));
+
+ result = Dart_LibraryId(lib, &libraryId);
+ EXPECT_VALID(result);
+ Dart_Handle libFromId = Dart_GetLibraryFromId(libraryId);
+ EXPECT(Dart_IsLibrary(libFromId));
+ result = Dart_LibraryName(libFromId);
+ EXPECT(Dart_IsString(result));
+ const char* cstr = NULL;
+ EXPECT_VALID(Dart_StringToCString(result, &cstr));
+ EXPECT_STREQ("library1_name", cstr);
+}
+
TEST_CASE(LibraryUrl) {
const char* kLibrary1Chars =

Powered by Google App Engine
This is Rietveld 408576698