Add tests for conflicting interfaces.

For IBar extends IFoo if 1.0::IFoo/default is being registered, remove
IFoo/default. This makes sure the following two things are equivalent
1). IBar::castFrom(IFoo::getService(X))
2). IBar::getService(X)

Test: hidl_test
Bug: 62303973
Change-Id: I3bb106f597b694d20d96fb3aaeed8abe04e0c229
diff --git a/test/hidl_test/hidl_test_client.cpp b/test/hidl_test/hidl_test_client.cpp
index 96d271c..aa3cded 100644
--- a/test/hidl_test/hidl_test_client.cpp
+++ b/test/hidl_test/hidl_test_client.cpp
@@ -608,6 +608,26 @@
     }
 }
 
+TEST_F(HidlTest, SubInterfaceServiceRegistrationTest) {
+    using ::android::hardware::interfacesEqual;
+
+    const std::string kInstanceName = "no-matter-what-it-is";
+    sp<IChild> child = new SimpleChild();
+    sp<IParent> parent = new SimpleParent();
+
+    EXPECT_EQ(::android::OK, child->registerAsService(kInstanceName));
+
+    EXPECT_TRUE(interfacesEqual(child, IChild::getService(kInstanceName)));
+    EXPECT_TRUE(interfacesEqual(child, IParent::getService(kInstanceName)));
+
+    EXPECT_EQ(::android::OK, parent->registerAsService(kInstanceName));
+
+    // FALSE since passthrough HAL will return an instance
+    // since binderized instance is nullptr
+    EXPECT_FALSE(interfacesEqual(parent, IChild::getService(kInstanceName)));
+    EXPECT_TRUE(interfacesEqual(parent, IParent::getService(kInstanceName)));
+}
+
 // passthrough TODO(b/31959402)
 TEST_F(HidlTest, ServiceParentTest) {
     if (mode == BINDERIZED) {