Loading confirmationui/1.0/vts/functional/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -27,5 +27,5 @@ cc_test { "libcn-cbor", "android.hardware.confirmationui-support-lib", ], test_suites: ["general-tests"], test_suites: ["general-tests", "vts-core"], } confirmationui/1.0/vts/functional/VtsHalConfirmationUIV1_0TargetTest.cpp +50 −74 Original line number Diff line number Diff line Loading @@ -26,8 +26,12 @@ #include <android/hardware/confirmationui/1.0/types.h> #include <android/hardware/confirmationui/support/confirmationui_utils.h> #include <gtest/gtest.h> #include <VtsHalHidlTargetCallbackBase.h> #include <VtsHalHidlTargetTestBase.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> #include <openssl/hmac.h> #include <openssl/sha.h> Loading Loading @@ -199,43 +203,18 @@ class ConfirmationTestCallback : public ::testing::VtsHalHidlTargetCallbackBase< } }; class ConfirmationUIHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { public: // get the test environment singleton static ConfirmationUIHidlEnvironment* Instance() { static ConfirmationUIHidlEnvironment* instance = new ConfirmationUIHidlEnvironment; return instance; } void registerTestServices() override { registerTestService<IConfirmationUI>(); } private: ConfirmationUIHidlEnvironment(){}; GTEST_DISALLOW_COPY_AND_ASSIGN_(ConfirmationUIHidlEnvironment); }; class ConfirmationUIHidlTest : public ::testing::VtsHalHidlTargetTestBase { class ConfirmationUIHidlTest : public ::testing::TestWithParam<std::string> { public: void TearDown() override { confirmator().abort(); } static void SetUpTestCase() { string service_name = ConfirmationUIHidlEnvironment::Instance()->getServiceName<IConfirmationUI>(); confirmator_ = IConfirmationUI::getService(service_name); void TearDown() override { confirmator_->abort(); } void SetUp() override { confirmator_ = IConfirmationUI::getService(GetParam()); ASSERT_NE(nullptr, confirmator_.get()); } static void TearDownTestCase() { confirmator_.clear(); } static IConfirmationUI& confirmator() { return *confirmator_; } private: static sp<IConfirmationUI> confirmator_; protected: sp<IConfirmationUI> confirmator_; }; sp<IConfirmationUI> ConfirmationUIHidlTest::confirmator_; #define ASSERT_HAL_CALL(expected, call) \ { \ auto result = call; \ Loading @@ -250,16 +229,16 @@ struct CnCborDeleter { typedef std::unique_ptr<cn_cbor, CnCborDeleter> CnCborPtr; // Simulates the User taping Ok TEST_F(ConfirmationUIHidlTest, UserOkTest) { TEST_P(ConfirmationUIHidlTest, UserOkTest) { static constexpr char test_prompt[] = "Me first, gimme gimme!"; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().deliverSecureInputEvent( ASSERT_HAL_CALL(ResponseCode::OK, confirmator_->deliverSecureInputEvent( makeTestToken(TestModeCommands::OK_EVENT))); auto result = conf_cb->WaitForCallback(); Loading Loading @@ -294,39 +273,39 @@ TEST_F(ConfirmationUIHidlTest, UserOkTest) { } // Initiates a confirmation prompt with a message that is too long TEST_F(ConfirmationUIHidlTest, MessageTooLongTest) { TEST_P(ConfirmationUIHidlTest, MessageTooLongTest) { static constexpr uint8_t test_extra[static_cast<uint32_t>(MessageSize::MAX)] = {}; static constexpr char test_prompt[] = "D\'oh!"; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + sizeof(test_extra)); ASSERT_HAL_CALL(ResponseCode::UIErrorMessageTooLong, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // If the message gets very long some HAL implementations might fail even before the message // reaches the trusted app implementation. But the HAL must still diagnose the correct error. TEST_F(ConfirmationUIHidlTest, MessageWayTooLongTest) { TEST_P(ConfirmationUIHidlTest, MessageWayTooLongTest) { static constexpr uint8_t test_extra[static_cast<uint32_t>(MessageSize::MAX) * 10] = {}; static constexpr char test_prompt[] = "D\'oh!"; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + sizeof(test_extra)); ASSERT_HAL_CALL(ResponseCode::UIErrorMessageTooLong, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Simulates the User tapping the Cancel TEST_F(ConfirmationUIHidlTest, UserCancelTest) { TEST_P(ConfirmationUIHidlTest, UserCancelTest) { static constexpr char test_prompt[] = "Me first, gimme gimme!"; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().deliverSecureInputEvent( ASSERT_HAL_CALL(ResponseCode::OK, confirmator_->deliverSecureInputEvent( makeTestToken(TestModeCommands::CANCEL_EVENT))); auto result = conf_cb->WaitForCallback(); Loading @@ -337,16 +316,16 @@ TEST_F(ConfirmationUIHidlTest, UserCancelTest) { } // Simulates the framework cancelling an ongoing prompt TEST_F(ConfirmationUIHidlTest, AbortTest) { TEST_P(ConfirmationUIHidlTest, AbortTest) { static constexpr char test_prompt[] = "Me first, gimme gimme!"; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -356,7 +335,7 @@ TEST_F(ConfirmationUIHidlTest, AbortTest) { // Tests if the confirmation dialog can successfully render 100 'W' characters as required by // the design guidelines. TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest1) { static constexpr char test_prompt[] = "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWW"; Loading @@ -365,9 +344,9 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -377,7 +356,7 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) { // Tests if the confirmation dialog can successfully render 100 'W' characters as required by // the design guidelines in magnified mode. TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { static constexpr char test_prompt[] = "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWW"; Loading @@ -386,10 +365,10 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {UIOption::AccessibilityMagnified})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -399,7 +378,7 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { // Tests if the confirmation dialog can successfully render 8 groups of 12 'W' characters as // required by the design guidelines. TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest2) { static constexpr char test_prompt[] = "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW " "WWWWWWWWWWWW WWWWWWWWWWWW"; Loading @@ -408,9 +387,9 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -420,7 +399,7 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) { // Tests if the confirmation dialog can successfully render 8 groups of 12 'W' characters as // required by the design guidelines in magnified mode. TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { static constexpr char test_prompt[] = "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW " "WWWWWWWWWWWW WWWWWWWWWWWW"; Loading @@ -429,10 +408,10 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {UIOption::AccessibilityMagnified})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -442,19 +421,19 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { // Passing malformed UTF-8 to the confirmation UI // This test passes a string that ends in the middle of a multibyte character TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test1) { TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test1) { static constexpr char test_prompt[] = {char(0xc0), 0}; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Passing malformed UTF-8 to the confirmation UI // This test passes a string with a 5-byte character. TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test2) { TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test2) { static constexpr char test_prompt[] = {char(0xf8), char(0x82), char(0x82), char(0x82), char(0x82), 0}; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; Loading @@ -462,19 +441,19 @@ TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test2) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Passing malformed UTF-8 to the confirmation UI // This test passes a string with a 2-byte character followed by a stray non UTF-8 character. TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test3) { TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test3) { static constexpr char test_prompt[] = {char(0xc0), char(0x82), char(0x83), 0}; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Test the implementation of HMAC SHA 256 against a golden blob. Loading @@ -494,16 +473,13 @@ TEST(ConfirmationUITestSelfTest, HMAC256SelfTest) { ASSERT_EQ(expected, result.value()); } INSTANTIATE_TEST_SUITE_P( PerInstance, ConfirmationUIHidlTest, testing::ValuesIn(android::hardware::getAllHalInstanceNames(IConfirmationUI::descriptor)), android::hardware::PrintInstanceNameToString); } // namespace test } // namespace V1_0 } // namespace confirmationui } // namespace hardware } // namespace android int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); std::vector<std::string> positional_args; int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; } Loading
confirmationui/1.0/vts/functional/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -27,5 +27,5 @@ cc_test { "libcn-cbor", "android.hardware.confirmationui-support-lib", ], test_suites: ["general-tests"], test_suites: ["general-tests", "vts-core"], }
confirmationui/1.0/vts/functional/VtsHalConfirmationUIV1_0TargetTest.cpp +50 −74 Original line number Diff line number Diff line Loading @@ -26,8 +26,12 @@ #include <android/hardware/confirmationui/1.0/types.h> #include <android/hardware/confirmationui/support/confirmationui_utils.h> #include <gtest/gtest.h> #include <VtsHalHidlTargetCallbackBase.h> #include <VtsHalHidlTargetTestBase.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> #include <openssl/hmac.h> #include <openssl/sha.h> Loading Loading @@ -199,43 +203,18 @@ class ConfirmationTestCallback : public ::testing::VtsHalHidlTargetCallbackBase< } }; class ConfirmationUIHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { public: // get the test environment singleton static ConfirmationUIHidlEnvironment* Instance() { static ConfirmationUIHidlEnvironment* instance = new ConfirmationUIHidlEnvironment; return instance; } void registerTestServices() override { registerTestService<IConfirmationUI>(); } private: ConfirmationUIHidlEnvironment(){}; GTEST_DISALLOW_COPY_AND_ASSIGN_(ConfirmationUIHidlEnvironment); }; class ConfirmationUIHidlTest : public ::testing::VtsHalHidlTargetTestBase { class ConfirmationUIHidlTest : public ::testing::TestWithParam<std::string> { public: void TearDown() override { confirmator().abort(); } static void SetUpTestCase() { string service_name = ConfirmationUIHidlEnvironment::Instance()->getServiceName<IConfirmationUI>(); confirmator_ = IConfirmationUI::getService(service_name); void TearDown() override { confirmator_->abort(); } void SetUp() override { confirmator_ = IConfirmationUI::getService(GetParam()); ASSERT_NE(nullptr, confirmator_.get()); } static void TearDownTestCase() { confirmator_.clear(); } static IConfirmationUI& confirmator() { return *confirmator_; } private: static sp<IConfirmationUI> confirmator_; protected: sp<IConfirmationUI> confirmator_; }; sp<IConfirmationUI> ConfirmationUIHidlTest::confirmator_; #define ASSERT_HAL_CALL(expected, call) \ { \ auto result = call; \ Loading @@ -250,16 +229,16 @@ struct CnCborDeleter { typedef std::unique_ptr<cn_cbor, CnCborDeleter> CnCborPtr; // Simulates the User taping Ok TEST_F(ConfirmationUIHidlTest, UserOkTest) { TEST_P(ConfirmationUIHidlTest, UserOkTest) { static constexpr char test_prompt[] = "Me first, gimme gimme!"; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().deliverSecureInputEvent( ASSERT_HAL_CALL(ResponseCode::OK, confirmator_->deliverSecureInputEvent( makeTestToken(TestModeCommands::OK_EVENT))); auto result = conf_cb->WaitForCallback(); Loading Loading @@ -294,39 +273,39 @@ TEST_F(ConfirmationUIHidlTest, UserOkTest) { } // Initiates a confirmation prompt with a message that is too long TEST_F(ConfirmationUIHidlTest, MessageTooLongTest) { TEST_P(ConfirmationUIHidlTest, MessageTooLongTest) { static constexpr uint8_t test_extra[static_cast<uint32_t>(MessageSize::MAX)] = {}; static constexpr char test_prompt[] = "D\'oh!"; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + sizeof(test_extra)); ASSERT_HAL_CALL(ResponseCode::UIErrorMessageTooLong, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // If the message gets very long some HAL implementations might fail even before the message // reaches the trusted app implementation. But the HAL must still diagnose the correct error. TEST_F(ConfirmationUIHidlTest, MessageWayTooLongTest) { TEST_P(ConfirmationUIHidlTest, MessageWayTooLongTest) { static constexpr uint8_t test_extra[static_cast<uint32_t>(MessageSize::MAX) * 10] = {}; static constexpr char test_prompt[] = "D\'oh!"; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + sizeof(test_extra)); ASSERT_HAL_CALL(ResponseCode::UIErrorMessageTooLong, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Simulates the User tapping the Cancel TEST_F(ConfirmationUIHidlTest, UserCancelTest) { TEST_P(ConfirmationUIHidlTest, UserCancelTest) { static constexpr char test_prompt[] = "Me first, gimme gimme!"; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().deliverSecureInputEvent( ASSERT_HAL_CALL(ResponseCode::OK, confirmator_->deliverSecureInputEvent( makeTestToken(TestModeCommands::CANCEL_EVENT))); auto result = conf_cb->WaitForCallback(); Loading @@ -337,16 +316,16 @@ TEST_F(ConfirmationUIHidlTest, UserCancelTest) { } // Simulates the framework cancelling an ongoing prompt TEST_F(ConfirmationUIHidlTest, AbortTest) { TEST_P(ConfirmationUIHidlTest, AbortTest) { static constexpr char test_prompt[] = "Me first, gimme gimme!"; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -356,7 +335,7 @@ TEST_F(ConfirmationUIHidlTest, AbortTest) { // Tests if the confirmation dialog can successfully render 100 'W' characters as required by // the design guidelines. TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest1) { static constexpr char test_prompt[] = "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWW"; Loading @@ -365,9 +344,9 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -377,7 +356,7 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) { // Tests if the confirmation dialog can successfully render 100 'W' characters as required by // the design guidelines in magnified mode. TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { static constexpr char test_prompt[] = "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWW"; Loading @@ -386,10 +365,10 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {UIOption::AccessibilityMagnified})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -399,7 +378,7 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) { // Tests if the confirmation dialog can successfully render 8 groups of 12 'W' characters as // required by the design guidelines. TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest2) { static constexpr char test_prompt[] = "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW " "WWWWWWWWWWWW WWWWWWWWWWWW"; Loading @@ -408,9 +387,9 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -420,7 +399,7 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) { // Tests if the confirmation dialog can successfully render 8 groups of 12 'W' characters as // required by the design guidelines in magnified mode. TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { TEST_P(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { static constexpr char test_prompt[] = "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW " "WWWWWWWWWWWW WWWWWWWWWWWW"; Loading @@ -429,10 +408,10 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::OK, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {UIOption::AccessibilityMagnified})); confirmator().abort(); confirmator_->abort(); auto result = conf_cb->WaitForCallback(); ASSERT_EQ(ResponseCode::Aborted, result.args->error_); Loading @@ -442,19 +421,19 @@ TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) { // Passing malformed UTF-8 to the confirmation UI // This test passes a string that ends in the middle of a multibyte character TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test1) { TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test1) { static constexpr char test_prompt[] = {char(0xc0), 0}; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Passing malformed UTF-8 to the confirmation UI // This test passes a string with a 5-byte character. TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test2) { TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test2) { static constexpr char test_prompt[] = {char(0xf8), char(0x82), char(0x82), char(0x82), char(0x82), 0}; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; Loading @@ -462,19 +441,19 @@ TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test2) { hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Passing malformed UTF-8 to the confirmation UI // This test passes a string with a 2-byte character followed by a stray non UTF-8 character. TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test3) { TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test3) { static constexpr char test_prompt[] = {char(0xc0), char(0x82), char(0x83), 0}; static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3}; sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback; hidl_string prompt_text(test_prompt); hidl_vec<uint8_t> extra(test_extra, test_extra + 3); ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding, confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {})); } // Test the implementation of HMAC SHA 256 against a golden blob. Loading @@ -494,16 +473,13 @@ TEST(ConfirmationUITestSelfTest, HMAC256SelfTest) { ASSERT_EQ(expected, result.value()); } INSTANTIATE_TEST_SUITE_P( PerInstance, ConfirmationUIHidlTest, testing::ValuesIn(android::hardware::getAllHalInstanceNames(IConfirmationUI::descriptor)), android::hardware::PrintInstanceNameToString); } // namespace test } // namespace V1_0 } // namespace confirmationui } // namespace hardware } // namespace android int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); std::vector<std::string> positional_args; int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; }