summaryrefslogtreecommitdiff
path: root/libnativebridge/tests/libnativebridge_api_test.cpp
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2024-03-04 16:48:02 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-03-18 13:49:05 +0000
commita87f1265e210615f7c90151f04a104a38067c196 (patch)
tree6e9ad36b34d3a1c57f5835e9662672d31cfb6032 /libnativebridge/tests/libnativebridge_api_test.cpp
parent921c42389cf15b42b09f8364ad438ccc18f07e71 (diff)
Revert "libnativebridge_test: link non-public libs statically" and fix
the CTS test to only call exported APIs. Reverts commit 7f5b3d89f21edd958ddb9d7bd01e03c77bd5425a. CTS tests need to link the libraries they test dynamically, and this test only tests exported stable APIs. The standalone CTS test config template includes NativeBridgeModuleController, so the test won't run in a translated environment (which has no proxy for this library and hence caused the error that prompted commit 7f5b3d89f21edd958ddb9d7bd01e03c77bd5425a). The test also used to test some non-exported APIs, which it shouldn't do in CTS. This changes it to use art_standalone_test_defaults, which doesn't have the test_for attributes that made it bypass the stub. Also reuse the trivial API-only tests for libnativebridge_lazy, and give them a more apt name for the new use. Test: atest art_libnativebridge_cts_tests \ libnativebridge-lazy-tests Test: art/libnativebridge/tests/runtests.sh Bug: 327407752 Change-Id: Ib56148f1a651a9ffa3045bc401cc625e6f42416b
Diffstat (limited to 'libnativebridge/tests/libnativebridge_api_test.cpp')
-rw-r--r--libnativebridge/tests/libnativebridge_api_test.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/libnativebridge/tests/libnativebridge_api_test.cpp b/libnativebridge/tests/libnativebridge_api_test.cpp
new file mode 100644
index 0000000000..037587cd81
--- /dev/null
+++ b/libnativebridge/tests/libnativebridge_api_test.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/macros.h>
+#include <gtest/gtest.h>
+
+#include "nativebridge/native_bridge.h"
+
+namespace android {
+
+class NativeBridgeApiTest : public ::testing::Test {};
+
+// Test the exported API in libnativebridge and libnativebridge_lazy.
+// The testing we can do here is limited since there's no exported API to
+// actually load the native bridge, but we only need to test the trivial
+// wrappers.
+
+TEST_F(NativeBridgeApiTest, NeedsNativeBridge) {
+ EXPECT_FALSE(NeedsNativeBridge(ABI_STRING));
+}
+
+TEST_F(NativeBridgeApiTest, PreInitializeNativeBridge) {
+ EXPECT_FALSE(PreInitializeNativeBridge(nullptr, ""));
+}
+
+TEST_F(NativeBridgeApiTest, NativeBridgeAvailable) {
+ EXPECT_FALSE(NativeBridgeAvailable());
+}
+
+TEST_F(NativeBridgeApiTest, NativeBridgeInitialized) {
+ EXPECT_FALSE(NativeBridgeInitialized());
+}
+
+TEST_F(NativeBridgeApiTest, NativeBridgeGetTrampoline) {
+ EXPECT_EQ(nullptr, NativeBridgeGetTrampoline(nullptr, nullptr, nullptr, 0));
+}
+
+TEST_F(NativeBridgeApiTest, NativeBridgeGetError) {
+ EXPECT_STREQ("native bridge is not initialized", NativeBridgeGetError());
+}
+
+}; // namespace android