diff options
| -rw-r--r-- | test/hidl_test/hidl_test_client.cpp | 46 | ||||
| -rw-r--r-- | test/java_test/hidl_test_java_native.cpp | 36 | ||||
| -rw-r--r-- | test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java | 31 |
3 files changed, 26 insertions, 87 deletions
diff --git a/test/hidl_test/hidl_test_client.cpp b/test/hidl_test/hidl_test_client.cpp index 2f3da3f6f..eff40a54c 100644 --- a/test/hidl_test/hidl_test_client.cpp +++ b/test/hidl_test/hidl_test_client.cpp @@ -33,7 +33,6 @@ #include <android/hardware/tests/inheritance/1.0/IParent.h> #include <android/hardware/tests/memory/1.0/IMemoryTest.h> #include <android/hardware/tests/multithread/1.0/IMultithread.h> -#include <android/hardware/tests/safeunion/1.0/IOtherInterface.h> #include <android/hardware/tests/safeunion/1.0/ISafeUnion.h> #include <android/hardware/tests/safeunion/cpp/1.0/ICppSafeUnion.h> #include <android/hardware/tests/trie/1.0/ITrie.h> @@ -133,7 +132,6 @@ using ::android::hardware::tests::inheritance::V1_0::IParent; using ::android::hardware::tests::memory::V1_0::IMemoryTest; using ::android::hardware::tests::multithread::V1_0::IMultithread; using ::android::hardware::tests::safeunion::cpp::V1_0::ICppSafeUnion; -using ::android::hardware::tests::safeunion::V1_0::IOtherInterface; using ::android::hardware::tests::safeunion::V1_0::ISafeUnion; using ::android::hardware::tests::trie::V1_0::ITrie; using ::android::hardware::tests::trie::V1_0::TrieNode; @@ -311,16 +309,6 @@ private: int32_t mCookie; }; -struct OtherInterface : public IOtherInterface { - Return<void> concatTwoStrings(const hidl_string& a, const hidl_string& b, - concatTwoStrings_cb _hidl_cb) override { - hidl_string result = std::string(a) + std::string(b); - _hidl_cb(result); - - return Void(); - } -}; - struct ServiceNotification : public IServiceNotification { std::mutex mutex; std::condition_variable condition; @@ -1648,7 +1636,7 @@ TEST_F(HidlTest, BazStructWithInterfaceTest) { swi.array = testArray; swi.oneString = testString; swi.vectorOfStrings = testStrings; - swi.dummy = baz; + swi.iface = baz; EXPECT_OK(baz->haveSomeStructWithInterface(swi, [&](const IBaz::StructWithInterface& swiBack) { EXPECT_EQ(42, swiBack.number); @@ -1659,9 +1647,7 @@ TEST_F(HidlTest, BazStructWithInterfaceTest) { EXPECT_EQ(testString, std::string(swiBack.oneString)); EXPECT_EQ(testStrings, swiBack.vectorOfStrings); - EXPECT_TRUE(interfacesEqual(swi.dummy, swiBack.dummy)); - EXPECT_OK(swiBack.dummy->someBoolVectorMethod( - testVector, [&](const hidl_vec<bool>& result) { EXPECT_EQ(goldenResult, result); })); + EXPECT_TRUE(interfacesEqual(swi.iface, swiBack.iface)); })); } @@ -2143,7 +2129,7 @@ TEST_F(HidlTest, SafeUnionUninit) { } TEST_F(HidlTest, SafeUnionMoveConstructorTest) { - sp<IOtherInterface> otherInterface = new OtherInterface(); + sp<SimpleChild> otherInterface = new SimpleChild(); ASSERT_EQ(1, otherInterface->getStrongCount()); InterfaceTypeSafeUnion safeUnion; @@ -2172,7 +2158,7 @@ TEST_F(HidlTest, SafeUnionCopyAssignmentTest) { } TEST_F(HidlTest, SafeUnionMoveAssignmentTest) { - sp<IOtherInterface> otherInterface = new OtherInterface(); + sp<SimpleChild> otherInterface = new SimpleChild(); ASSERT_EQ(1, otherInterface->getStrongCount()); InterfaceTypeSafeUnion safeUnion; @@ -2243,10 +2229,6 @@ TEST_F(HidlTest, SafeUnionInterfaceTest) { const std::string testStringA = "Hello"; const std::string testStringB = "World"; - const std::string serviceName = "otherinterface"; - sp<IOtherInterface> otherInterface = new OtherInterface(); - EXPECT_EQ(::android::OK, otherInterface->registerAsService(serviceName)); - EXPECT_OK( safeunionInterface->newInterfaceTypeSafeUnion([&](const InterfaceTypeSafeUnion& safeUnion) { EXPECT_EQ(InterfaceTypeSafeUnion::hidl_discriminator::noinit, @@ -2262,15 +2244,13 @@ TEST_F(HidlTest, SafeUnionInterfaceTest) { } EXPECT_OK(safeunionInterface->setInterfaceC( - safeUnion, otherInterface, [&](const InterfaceTypeSafeUnion& safeUnion) { - EXPECT_EQ(InterfaceTypeSafeUnion::hidl_discriminator::c, - safeUnion.getDiscriminator()); - - EXPECT_OK(safeUnion.c()->concatTwoStrings( - testStringA, testStringB, [&](const hidl_string& result) { - EXPECT_EQ(testStringA + testStringB, std::string(result)); - })); - })); + safeUnion, manager, [&](const InterfaceTypeSafeUnion& safeUnion) { + EXPECT_EQ(InterfaceTypeSafeUnion::hidl_discriminator::c, + safeUnion.getDiscriminator()); + + using ::android::hardware::interfacesEqual; + EXPECT_TRUE(interfacesEqual(safeUnion.c(), manager)); + })); })); EXPECT_OK(safeunionInterface->setInterfaceD( @@ -2499,7 +2479,7 @@ TEST_F(HidlTest, SafeUnionEqualityTest) { } TEST_F(HidlTest, SafeUnionSimpleDestructorTest) { - sp<IOtherInterface> otherInterface = new OtherInterface(); + sp<SimpleChild> otherInterface = new SimpleChild(); ASSERT_EQ(1, otherInterface->getStrongCount()); { @@ -2512,7 +2492,7 @@ TEST_F(HidlTest, SafeUnionSimpleDestructorTest) { } TEST_F(HidlTest, SafeUnionSwitchActiveComponentsDestructorTest) { - sp<IOtherInterface> otherInterface = new OtherInterface(); + sp<SimpleChild> otherInterface = new SimpleChild(); ASSERT_EQ(1, otherInterface->getStrongCount()); InterfaceTypeSafeUnion safeUnion; diff --git a/test/java_test/hidl_test_java_native.cpp b/test/java_test/hidl_test_java_native.cpp index bbc8f554d..325bb8319 100644 --- a/test/java_test/hidl_test_java_native.cpp +++ b/test/java_test/hidl_test_java_native.cpp @@ -23,9 +23,9 @@ #include <android/hardware/tests/baz/1.0/IBaz.h> #include <android/hardware/tests/memory/2.0/IMemoryInterface.h> #include <android/hardware/tests/memory/2.0/types.h> -#include <android/hardware/tests/safeunion/1.0/IOtherInterface.h> #include <android/hardware/tests/safeunion/1.0/ISafeUnion.h> #include <android/hidl/allocator/1.0/IAllocator.h> +#include <android/hidl/manager/1.0/IServiceManager.h> #include <hidlmemory/mapping.h> #include <hidl/LegacySupport.h> @@ -44,7 +44,6 @@ using ::android::hardware::tests::baz::V1_0::IBaz; using ::android::hardware::tests::baz::V1_0::IBazCallback; using ::android::hardware::tests::memory::V2_0::IMemoryInterface; using ::android::hardware::tests::memory::V2_0::TwoMemory; -using ::android::hardware::tests::safeunion::V1_0::IOtherInterface; using ::android::hardware::tests::safeunion::V1_0::ISafeUnion; using ::android::hardware::hidl_array; @@ -83,16 +82,6 @@ Return<void> BazCallback::hey() { return Void(); } -struct OtherInterface : public IOtherInterface { - Return<void> concatTwoStrings(const hidl_string& a, const hidl_string& b, - concatTwoStrings_cb _hidl_cb) override { - hidl_string result = std::string(a) + std::string(b); - _hidl_cb(result); - - return Void(); - } -}; - struct MemoryInterface : public IMemoryInterface { MemoryInterface() { sp<IAllocator> ashmem = IAllocator::getService("ashmem"); @@ -222,7 +211,6 @@ struct HidlEnvironment : public ::testing::Environment { struct HidlTest : public ::testing::Test { sp<IBaz> baz; sp<ISafeUnion> safeunionInterface; - sp<IOtherInterface> otherInterface; void SetUp() override { using namespace ::android::hardware; @@ -236,11 +224,6 @@ struct HidlTest : public ::testing::Test { safeunionInterface = ISafeUnion::getService(); CHECK(safeunionInterface != nullptr); CHECK(safeunionInterface->isRemote()); - - ::android::hardware::details::waitForHwService(IOtherInterface::descriptor, "default"); - otherInterface = IOtherInterface::getService(); - CHECK(otherInterface != nullptr); - CHECK(otherInterface->isRemote()); } void TearDown() override { @@ -979,17 +962,14 @@ TEST_F(HidlTest, SafeUnionInterfaceTest) { })); })); - // Same-process interface calls are not supported in Java, so we use - // a safe_union instance bound to this (client) process instead of - // safeunionInterface to exercise this test-case. Ref: b/110957763. + using android::hardware::defaultServiceManager; + using android::hardware::interfacesEqual; + InterfaceTypeSafeUnion safeUnion; - safeUnion.c(otherInterface); + safeUnion.c(defaultServiceManager()); EXPECT_EQ(InterfaceTypeSafeUnion::hidl_discriminator::c, safeUnion.getDiscriminator()); - EXPECT_OK(safeUnion.c()->concatTwoStrings( - hidl_string(testStringA), hidl_string(testStringB), [&](const hidl_string& result) { - EXPECT_EQ(testStringA + testStringB, std::string(result)); - })); + EXPECT_TRUE(interfacesEqual(safeUnion.c(), defaultServiceManager())); native_handle_delete(h); } @@ -1300,10 +1280,6 @@ int main(int argc, char **argv) { status = registerPassthroughServiceImplementation<ISafeUnion>(); CHECK(status == ::android::OK) << "ISafeUnion didn't register"; - sp<IOtherInterface> otherInterface = new OtherInterface(); - status = otherInterface->registerAsService(); - CHECK(status == ::android::OK) << "IOtherInterface didn't register"; - sp<IMemoryInterface> memoryInterface = new MemoryInterface(); status = memoryInterface->registerAsService(); CHECK(status == ::android::OK) << "IMemoryInterface didn't register"; diff --git a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java index a63093ea9..a0311fedb 100644 --- a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java +++ b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java @@ -28,7 +28,6 @@ import android.hardware.tests.baz.V1_0.IBazCallback; import android.hardware.tests.baz.V1_0.IQuux; import android.hardware.tests.memory.V2_0.IMemoryInterface; import android.hardware.tests.memory.V2_0.TwoMemory; -import android.hardware.tests.safeunion.V1_0.IOtherInterface; import android.hardware.tests.safeunion.V1_0.ISafeUnion; import android.hardware.tests.safeunion.V1_0.ISafeUnion.HandleTypeSafeUnion; import android.hardware.tests.safeunion.V1_0.ISafeUnion.InterfaceTypeSafeUnion; @@ -369,8 +368,6 @@ public final class HidlTestJava { String testStringA = "Hello"; String testStringB = "World"; - IOtherInterface otherInterface = IOtherInterface.getService(); - ArrayList<NativeHandle> testHandlesVector = new ArrayList<>(); for (int i = 0; i < 128; i++) { testHandlesVector.add(new NativeHandle()); @@ -381,11 +378,10 @@ public final class HidlTestJava { ExpectTrue(safeUnion.getDiscriminator() == InterfaceTypeSafeUnion.hidl_discriminator.b); ExpectDeepEq(testArray, safeUnion.b()); - safeUnion.c(otherInterface); + IServiceManager anInterface = IServiceManager.getService(); + safeUnion.c(anInterface); ExpectTrue(safeUnion.getDiscriminator() == InterfaceTypeSafeUnion.hidl_discriminator.c); - ExpectTrue(HidlSupport.interfacesEqual(otherInterface, safeUnion.c())); - String result = safeUnion.c().concatTwoStrings(testStringA, testStringB); - Expect(result, testStringA + testStringB); + ExpectTrue(HidlSupport.interfacesEqual(anInterface, safeUnion.c())); safeUnion = safeunionInterface.setInterfaceD(safeUnion, testStringA); ExpectTrue(safeUnion.getDiscriminator() == InterfaceTypeSafeUnion.hidl_discriminator.d); @@ -1218,15 +1214,12 @@ public final class HidlTestJava { IBaz baz = IBaz.getService(); ExpectTrue(baz != null); IBaz.StructWithInterface swi = new IBaz.StructWithInterface(); - swi.dummy = baz; + swi.iface = IServiceManager.getService(); swi.number = 12345678; IBaz.StructWithInterface swi_back = baz.haveSomeStructWithInterface(swi); ExpectTrue(swi_back != null); - // TODO(b/169369810) - if (!proxy.isJava()) { - ExpectTrue(swi_back.dummy != null); - ExpectTrue(HidlSupport.interfacesEqual(baz, swi_back.dummy)); - } + ExpectTrue(swi_back.iface != null); + ExpectTrue(HidlSupport.interfacesEqual(swi.iface, swi_back.iface)); ExpectTrue(swi_back.number == 12345678); } @@ -1676,7 +1669,7 @@ public final class HidlTestJava { @Override public InterfaceTypeSafeUnion setInterfaceC( - InterfaceTypeSafeUnion safeUnion, IOtherInterface c) { + InterfaceTypeSafeUnion safeUnion, android.hidl.base.V1_0.IBase c) { Log.d(TAG, "SERVER: setInterfaceC(" + c + ")"); safeUnion.c(c); @@ -1750,13 +1743,6 @@ public final class HidlTestJava { } } - class OtherInterface extends IOtherInterface.Stub { - @Override - public String concatTwoStrings(String a, String b) { - return a.concat(b); - } - } - private void server() throws RemoteException { HwBinder.configureRpcThreadpool(1, true); @@ -1773,9 +1759,6 @@ public final class HidlTestJava { SafeUnion safeunionInterface = new SafeUnion(); safeunionInterface.registerAsService("default"); - OtherInterface otherInterface = new OtherInterface(); - otherInterface.registerAsService("default"); - HwBinder.joinRpcThreadpool(); } } |
