Loading security/keymint/aidl/vts/functional/KeyMintTest.cpp +44 −23 Original line number Diff line number Diff line Loading @@ -1064,15 +1064,35 @@ TEST_P(NewKeyGenerationTest, RsaWithMissingValidity) { TEST_P(NewKeyGenerationTest, RsaWithSpecifiedValidity) { vector<uint8_t> key_blob; vector<KeyCharacteristics> key_characteristics; vector<uint64_t> test_vector_not_before_millis = { 458046000000, /* 1984-07-07T11:00:00Z */ 1183806000000, /* 2007-07-07T11:00:00Z */ 1924991999000, /* 2030-12-31T23:59:59Z */ 3723753599000, /* 2087-12-31T23:59:59Z */ 26223868799000, /* 2800-12-31T23:59:59Z */ 45157996799000, /* 3400-12-31T23:59:59Z */ 60719587199000, /* 3894-02-15T23:59:59Z */ 95302051199000, /* 4989-12-31T23:59:59Z */ 86182012799000, /* 4700-12-31T23:59:59Z */ 111427574399000, /* 5500-12-31T23:59:59Z */ 136988668799000, /* 6310-12-31T23:59:59Z */ 139828895999000, /* 6400-12-31T23:59:59Z */ 169839503999000, /* 7351-12-31T23:59:59Z */ 171385804799000, /* 7400-12-31T23:59:59Z */ 190320019199000, /* 8000-12-31T23:59:59Z */ 193475692799000, /* 8100-12-31T23:59:59Z */ 242515209599000, /* 9654-12-31T23:59:59Z */ 250219065599000, /* 9899-02-15T23:59:59Z */ }; for (auto notBefore : test_vector_not_before_millis) { uint64_t notAfter = notBefore + 378691200000 /* 12 years milliseconds*/; ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder() .RsaSigningKey(2048, 65537) .Digest(Digest::NONE) .Padding(PaddingMode::NONE) .Authorization(TAG_CERTIFICATE_NOT_BEFORE, 1183806000000 /* 2007-07-07T11:00:00Z */) .Authorization(TAG_CERTIFICATE_NOT_AFTER, 1916049600000 /* 2030-09-19T12:00:00Z */), .Authorization(TAG_CERTIFICATE_NOT_BEFORE, notBefore) .Authorization(TAG_CERTIFICATE_NOT_AFTER, notAfter), &key_blob, &key_characteristics)); ASSERT_GT(cert_chain_.size(), 0); Loading @@ -1083,13 +1103,14 @@ TEST_P(NewKeyGenerationTest, RsaWithSpecifiedValidity) { ASSERT_NE(not_before, nullptr); time_t not_before_time; ASSERT_EQ(ASN1_TIME_to_time_t(not_before, ¬_before_time), 1); EXPECT_EQ(not_before_time, 1183806000); EXPECT_EQ(not_before_time, (notBefore / 1000)); const ASN1_TIME* not_after = X509_get0_notAfter(cert.get()); ASSERT_NE(not_after, nullptr); time_t not_after_time; ASSERT_EQ(ASN1_TIME_to_time_t(not_after, ¬_after_time), 1); EXPECT_EQ(not_after_time, 1916049600); EXPECT_EQ(not_after_time, (notAfter / 1000)); } } /* Loading vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +141 −123 Original line number Diff line number Diff line Loading @@ -109,6 +109,11 @@ class VibratorAidl : public testing::TestWithParam<std::tuple<int32_t, int32_t>> ASSERT_TRUE(vibrator->getCapabilities(&capabilities).isOk()); } virtual void TearDown() override { // Reset vibrator state between tests. EXPECT_TRUE(vibrator->off().isOk()); } sp<IVibrator> vibrator; int32_t capabilities; }; Loading Loading @@ -429,7 +434,10 @@ TEST_P(VibratorAidl, GetPrimitiveDuration) { } TEST_P(VibratorAidl, ComposeValidPrimitives) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } std::vector<CompositePrimitive> supported; int32_t maxDelay, maxSize; Loading @@ -439,30 +447,31 @@ TEST_P(VibratorAidl, ComposeValidPrimitives) { std::vector<CompositeEffect> composite; for (auto primitive : supported) { for (int i = 0; i < supported.size(); i++) { auto primitive = supported[i]; float t = static_cast<float>(i + 1) / supported.size(); CompositeEffect effect; effect.delayMs = std::rand() % (maxDelay + 1); effect.delayMs = maxDelay * t; effect.primitive = primitive; effect.scale = static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX); composite.emplace_back(effect); effect.scale = t; if (composite.size() == maxSize) { EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); composite.clear(); vibrator->off(); break; } } if (composite.size() != 0) { EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } EXPECT_TRUE(vibrator->off().isOk()); } } TEST_P(VibratorAidl, ComposeUnsupportedPrimitives) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } auto unsupported = kInvalidPrimitives; std::vector<CompositePrimitive> supported; Loading @@ -487,13 +496,14 @@ TEST_P(VibratorAidl, ComposeUnsupportedPrimitives) { } Status status = vibrator->compose(composite, nullptr); EXPECT_TRUE(isUnknownOrUnsupported(status)) << status; vibrator->off(); } } } TEST_P(VibratorAidl, ComposeScaleBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } std::vector<CompositeEffect> composite(1); CompositeEffect& effect = composite[0]; Loading @@ -501,50 +511,56 @@ TEST_P(VibratorAidl, ComposeScaleBoundary) { effect.primitive = CompositePrimitive::CLICK; effect.scale = std::nextafter(0.0f, -1.0f); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); effect.scale = 0.0f; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.scale = 1.0f; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.scale = std::nextafter(1.0f, 2.0f); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); } TEST_P(VibratorAidl, ComposeDelayBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } int32_t maxDelay; EXPECT_EQ(Status::EX_NONE, vibrator->getCompositionDelayMax(&maxDelay).exceptionCode()); std::vector<CompositeEffect> composite(1); CompositeEffect effect; CompositeEffect& effect = composite[0]; effect.delayMs = 1; effect.primitive = CompositePrimitive::CLICK; effect.scale = 1.0f; std::fill(composite.begin(), composite.end(), effect); effect.delayMs = 0; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.delayMs = maxDelay + 1; effect.delayMs = 1; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); std::fill(composite.begin(), composite.end(), effect); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } effect.delayMs = maxDelay; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.delayMs = maxDelay + 1; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); } TEST_P(VibratorAidl, ComposeSizeBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } int32_t maxSize; EXPECT_EQ(Status::EX_NONE, vibrator->getCompositionSizeMax(&maxSize).exceptionCode()); Loading @@ -558,16 +574,17 @@ TEST_P(VibratorAidl, ComposeSizeBoundary) { std::fill(composite.begin(), composite.end(), effect); EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); composite.emplace_back(effect); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); } TEST_P(VibratorAidl, ComposeCallback) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } std::vector<CompositePrimitive> supported; ASSERT_TRUE(vibrator->getSupportedPrimitives(&supported).isOk()); Loading Loading @@ -611,7 +628,8 @@ TEST_P(VibratorAidl, ComposeCallback) { elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start); EXPECT_GE(elapsed.count(), duration.count()) << toString(primitive); } EXPECT_TRUE(vibrator->off().isOk()); } } Loading vibrator/bench/benchmark.cpp +29 −10 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ class VibratorEffectsBench : public VibratorBench<I> { }); if (!supported) { state->SkipWithMessage("performApi returned UNSUPPORTED_OPERATION"); return; } Loading Loading @@ -145,6 +146,7 @@ class VibratorEffectsBench : public VibratorBench<I> { /* NOLINTNEXTLINE */ \ (State & state) { \ if (!mVibrator) { \ state.SkipWithMessage("HAL unavailable"); \ return; \ } \ \ Loading Loading @@ -186,6 +188,7 @@ BENCHMARK_WRAPPER(VibratorBench_V1_0, setAmplitude, { uint8_t amplitude = UINT8_MAX; if (!mVibrator->supportsAmplitudeControl()) { state.SkipWithMessage("Amplitude control unavailable"); return; } Loading Loading @@ -227,6 +230,7 @@ BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalControl, { bool enable = true; if (!mVibrator->supportsExternalControl()) { state.SkipWithMessage("external control unavailable"); return; } Loading @@ -240,6 +244,7 @@ BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalControl, { BENCHMARK_WRAPPER(VibratorBench_V1_3, supportsExternalAmplitudeControl, { if (!mVibrator->supportsExternalControl()) { state.SkipWithMessage("external control unavailable"); return; } Loading @@ -256,12 +261,14 @@ BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalAmplitude, { uint8_t amplitude = UINT8_MAX; if (!mVibrator->supportsExternalControl()) { state.SkipWithMessage("external control unavailable"); return; } mVibrator->setExternalControl(true); if (!mVibrator->supportsAmplitudeControl()) { state.SkipWithMessage("amplitude control unavailable"); return; } Loading Loading @@ -328,6 +335,7 @@ BENCHMARK_WRAPPER(VibratorBench_Aidl, setAmplitude, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_AMPLITUDE_CONTROL) == 0) { state.SkipWithMessage("amplitude control unavailable"); return; } Loading @@ -345,6 +353,7 @@ BENCHMARK_WRAPPER(VibratorBench_Aidl, setExternalControl, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_EXTERNAL_CONTROL) == 0) { state.SkipWithMessage("external control unavailable"); return; } Loading @@ -361,6 +370,7 @@ BENCHMARK_WRAPPER(VibratorBench_Aidl, setExternalAmplitude, { mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_EXTERNAL_CONTROL) == 0 || (capabilities & Aidl::IVibrator::CAP_EXTERNAL_AMPLITUDE_CONTROL) == 0) { state.SkipWithMessage("external amplitude control unavailable"); return; } Loading Loading @@ -423,6 +433,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnEnable, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_ALWAYS_ON_CONTROL) == 0) { state.SkipWithMessage("always on control unavailable"); return; } Loading @@ -433,6 +444,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnEnable, { std::vector<Aidl::Effect> supported; mVibrator->getSupportedAlwaysOnEffects(&supported); if (std::find(supported.begin(), supported.end(), effect) == supported.end()) { state.SkipWithMessage("always on effects unavailable"); return; } Loading @@ -448,6 +460,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnDisable, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_ALWAYS_ON_CONTROL) == 0) { state.SkipWithMessage("always on control unavailable"); return; } Loading @@ -458,6 +471,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnDisable, { std::vector<Aidl::Effect> supported; mVibrator->getSupportedAlwaysOnEffects(&supported); if (std::find(supported.begin(), supported.end(), effect) == supported.end()) { state.SkipWithMessage("always on effects unavailable"); return; } Loading @@ -481,6 +495,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, perform, { std::vector<Aidl::Effect> supported; mVibrator->getSupportedEffects(&supported); if (std::find(supported.begin(), supported.end(), effect) == supported.end()) { state.SkipWithMessage("effects unavailable"); return; } Loading Loading @@ -527,6 +542,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, getPrimitiveDuration, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_COMPOSE_EFFECTS) == 0) { state.SkipWithMessage("compose effects unavailable"); return; } Loading @@ -536,6 +552,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, getPrimitiveDuration, { std::vector<Aidl::CompositePrimitive> supported; mVibrator->getSupportedPrimitives(&supported); if (std::find(supported.begin(), supported.end(), primitive) == supported.end()) { state.SkipWithMessage("supported primitives unavailable"); return; } Loading @@ -548,6 +565,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, compose, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_COMPOSE_EFFECTS) == 0) { state.SkipWithMessage("compose effects unavailable"); return; } Loading @@ -559,6 +577,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, compose, { std::vector<Aidl::CompositePrimitive> supported; mVibrator->getSupportedPrimitives(&supported); if (std::find(supported.begin(), supported.end(), effect.primitive) == supported.end()) { state.SkipWithMessage("supported primitives unavailable"); return; } Loading Loading
security/keymint/aidl/vts/functional/KeyMintTest.cpp +44 −23 Original line number Diff line number Diff line Loading @@ -1064,15 +1064,35 @@ TEST_P(NewKeyGenerationTest, RsaWithMissingValidity) { TEST_P(NewKeyGenerationTest, RsaWithSpecifiedValidity) { vector<uint8_t> key_blob; vector<KeyCharacteristics> key_characteristics; vector<uint64_t> test_vector_not_before_millis = { 458046000000, /* 1984-07-07T11:00:00Z */ 1183806000000, /* 2007-07-07T11:00:00Z */ 1924991999000, /* 2030-12-31T23:59:59Z */ 3723753599000, /* 2087-12-31T23:59:59Z */ 26223868799000, /* 2800-12-31T23:59:59Z */ 45157996799000, /* 3400-12-31T23:59:59Z */ 60719587199000, /* 3894-02-15T23:59:59Z */ 95302051199000, /* 4989-12-31T23:59:59Z */ 86182012799000, /* 4700-12-31T23:59:59Z */ 111427574399000, /* 5500-12-31T23:59:59Z */ 136988668799000, /* 6310-12-31T23:59:59Z */ 139828895999000, /* 6400-12-31T23:59:59Z */ 169839503999000, /* 7351-12-31T23:59:59Z */ 171385804799000, /* 7400-12-31T23:59:59Z */ 190320019199000, /* 8000-12-31T23:59:59Z */ 193475692799000, /* 8100-12-31T23:59:59Z */ 242515209599000, /* 9654-12-31T23:59:59Z */ 250219065599000, /* 9899-02-15T23:59:59Z */ }; for (auto notBefore : test_vector_not_before_millis) { uint64_t notAfter = notBefore + 378691200000 /* 12 years milliseconds*/; ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder() .RsaSigningKey(2048, 65537) .Digest(Digest::NONE) .Padding(PaddingMode::NONE) .Authorization(TAG_CERTIFICATE_NOT_BEFORE, 1183806000000 /* 2007-07-07T11:00:00Z */) .Authorization(TAG_CERTIFICATE_NOT_AFTER, 1916049600000 /* 2030-09-19T12:00:00Z */), .Authorization(TAG_CERTIFICATE_NOT_BEFORE, notBefore) .Authorization(TAG_CERTIFICATE_NOT_AFTER, notAfter), &key_blob, &key_characteristics)); ASSERT_GT(cert_chain_.size(), 0); Loading @@ -1083,13 +1103,14 @@ TEST_P(NewKeyGenerationTest, RsaWithSpecifiedValidity) { ASSERT_NE(not_before, nullptr); time_t not_before_time; ASSERT_EQ(ASN1_TIME_to_time_t(not_before, ¬_before_time), 1); EXPECT_EQ(not_before_time, 1183806000); EXPECT_EQ(not_before_time, (notBefore / 1000)); const ASN1_TIME* not_after = X509_get0_notAfter(cert.get()); ASSERT_NE(not_after, nullptr); time_t not_after_time; ASSERT_EQ(ASN1_TIME_to_time_t(not_after, ¬_after_time), 1); EXPECT_EQ(not_after_time, 1916049600); EXPECT_EQ(not_after_time, (notAfter / 1000)); } } /* Loading
vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +141 −123 Original line number Diff line number Diff line Loading @@ -109,6 +109,11 @@ class VibratorAidl : public testing::TestWithParam<std::tuple<int32_t, int32_t>> ASSERT_TRUE(vibrator->getCapabilities(&capabilities).isOk()); } virtual void TearDown() override { // Reset vibrator state between tests. EXPECT_TRUE(vibrator->off().isOk()); } sp<IVibrator> vibrator; int32_t capabilities; }; Loading Loading @@ -429,7 +434,10 @@ TEST_P(VibratorAidl, GetPrimitiveDuration) { } TEST_P(VibratorAidl, ComposeValidPrimitives) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } std::vector<CompositePrimitive> supported; int32_t maxDelay, maxSize; Loading @@ -439,30 +447,31 @@ TEST_P(VibratorAidl, ComposeValidPrimitives) { std::vector<CompositeEffect> composite; for (auto primitive : supported) { for (int i = 0; i < supported.size(); i++) { auto primitive = supported[i]; float t = static_cast<float>(i + 1) / supported.size(); CompositeEffect effect; effect.delayMs = std::rand() % (maxDelay + 1); effect.delayMs = maxDelay * t; effect.primitive = primitive; effect.scale = static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX); composite.emplace_back(effect); effect.scale = t; if (composite.size() == maxSize) { EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); composite.clear(); vibrator->off(); break; } } if (composite.size() != 0) { EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } EXPECT_TRUE(vibrator->off().isOk()); } } TEST_P(VibratorAidl, ComposeUnsupportedPrimitives) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } auto unsupported = kInvalidPrimitives; std::vector<CompositePrimitive> supported; Loading @@ -487,13 +496,14 @@ TEST_P(VibratorAidl, ComposeUnsupportedPrimitives) { } Status status = vibrator->compose(composite, nullptr); EXPECT_TRUE(isUnknownOrUnsupported(status)) << status; vibrator->off(); } } } TEST_P(VibratorAidl, ComposeScaleBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } std::vector<CompositeEffect> composite(1); CompositeEffect& effect = composite[0]; Loading @@ -501,50 +511,56 @@ TEST_P(VibratorAidl, ComposeScaleBoundary) { effect.primitive = CompositePrimitive::CLICK; effect.scale = std::nextafter(0.0f, -1.0f); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); effect.scale = 0.0f; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.scale = 1.0f; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.scale = std::nextafter(1.0f, 2.0f); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); } TEST_P(VibratorAidl, ComposeDelayBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } int32_t maxDelay; EXPECT_EQ(Status::EX_NONE, vibrator->getCompositionDelayMax(&maxDelay).exceptionCode()); std::vector<CompositeEffect> composite(1); CompositeEffect effect; CompositeEffect& effect = composite[0]; effect.delayMs = 1; effect.primitive = CompositePrimitive::CLICK; effect.scale = 1.0f; std::fill(composite.begin(), composite.end(), effect); effect.delayMs = 0; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.delayMs = maxDelay + 1; effect.delayMs = 1; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); std::fill(composite.begin(), composite.end(), effect); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } effect.delayMs = maxDelay; EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); effect.delayMs = maxDelay + 1; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); } TEST_P(VibratorAidl, ComposeSizeBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } int32_t maxSize; EXPECT_EQ(Status::EX_NONE, vibrator->getCompositionSizeMax(&maxSize).exceptionCode()); Loading @@ -558,16 +574,17 @@ TEST_P(VibratorAidl, ComposeSizeBoundary) { std::fill(composite.begin(), composite.end(), effect); EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, nullptr).exceptionCode()); EXPECT_TRUE(vibrator->off().isOk()); composite.emplace_back(effect); EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); vibrator->off(); } EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->compose(composite, nullptr).exceptionCode()); } TEST_P(VibratorAidl, ComposeCallback) { if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) { if (!(capabilities & IVibrator::CAP_COMPOSE_EFFECTS)) { GTEST_SKIP() << "CAP_COMPOSE_EFFECTS not supported"; } std::vector<CompositePrimitive> supported; ASSERT_TRUE(vibrator->getSupportedPrimitives(&supported).isOk()); Loading Loading @@ -611,7 +628,8 @@ TEST_P(VibratorAidl, ComposeCallback) { elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start); EXPECT_GE(elapsed.count(), duration.count()) << toString(primitive); } EXPECT_TRUE(vibrator->off().isOk()); } } Loading
vibrator/bench/benchmark.cpp +29 −10 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ class VibratorEffectsBench : public VibratorBench<I> { }); if (!supported) { state->SkipWithMessage("performApi returned UNSUPPORTED_OPERATION"); return; } Loading Loading @@ -145,6 +146,7 @@ class VibratorEffectsBench : public VibratorBench<I> { /* NOLINTNEXTLINE */ \ (State & state) { \ if (!mVibrator) { \ state.SkipWithMessage("HAL unavailable"); \ return; \ } \ \ Loading Loading @@ -186,6 +188,7 @@ BENCHMARK_WRAPPER(VibratorBench_V1_0, setAmplitude, { uint8_t amplitude = UINT8_MAX; if (!mVibrator->supportsAmplitudeControl()) { state.SkipWithMessage("Amplitude control unavailable"); return; } Loading Loading @@ -227,6 +230,7 @@ BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalControl, { bool enable = true; if (!mVibrator->supportsExternalControl()) { state.SkipWithMessage("external control unavailable"); return; } Loading @@ -240,6 +244,7 @@ BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalControl, { BENCHMARK_WRAPPER(VibratorBench_V1_3, supportsExternalAmplitudeControl, { if (!mVibrator->supportsExternalControl()) { state.SkipWithMessage("external control unavailable"); return; } Loading @@ -256,12 +261,14 @@ BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalAmplitude, { uint8_t amplitude = UINT8_MAX; if (!mVibrator->supportsExternalControl()) { state.SkipWithMessage("external control unavailable"); return; } mVibrator->setExternalControl(true); if (!mVibrator->supportsAmplitudeControl()) { state.SkipWithMessage("amplitude control unavailable"); return; } Loading Loading @@ -328,6 +335,7 @@ BENCHMARK_WRAPPER(VibratorBench_Aidl, setAmplitude, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_AMPLITUDE_CONTROL) == 0) { state.SkipWithMessage("amplitude control unavailable"); return; } Loading @@ -345,6 +353,7 @@ BENCHMARK_WRAPPER(VibratorBench_Aidl, setExternalControl, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_EXTERNAL_CONTROL) == 0) { state.SkipWithMessage("external control unavailable"); return; } Loading @@ -361,6 +370,7 @@ BENCHMARK_WRAPPER(VibratorBench_Aidl, setExternalAmplitude, { mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_EXTERNAL_CONTROL) == 0 || (capabilities & Aidl::IVibrator::CAP_EXTERNAL_AMPLITUDE_CONTROL) == 0) { state.SkipWithMessage("external amplitude control unavailable"); return; } Loading Loading @@ -423,6 +433,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnEnable, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_ALWAYS_ON_CONTROL) == 0) { state.SkipWithMessage("always on control unavailable"); return; } Loading @@ -433,6 +444,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnEnable, { std::vector<Aidl::Effect> supported; mVibrator->getSupportedAlwaysOnEffects(&supported); if (std::find(supported.begin(), supported.end(), effect) == supported.end()) { state.SkipWithMessage("always on effects unavailable"); return; } Loading @@ -448,6 +460,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnDisable, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_ALWAYS_ON_CONTROL) == 0) { state.SkipWithMessage("always on control unavailable"); return; } Loading @@ -458,6 +471,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, alwaysOnDisable, { std::vector<Aidl::Effect> supported; mVibrator->getSupportedAlwaysOnEffects(&supported); if (std::find(supported.begin(), supported.end(), effect) == supported.end()) { state.SkipWithMessage("always on effects unavailable"); return; } Loading @@ -481,6 +495,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench_Aidl, perform, { std::vector<Aidl::Effect> supported; mVibrator->getSupportedEffects(&supported); if (std::find(supported.begin(), supported.end(), effect) == supported.end()) { state.SkipWithMessage("effects unavailable"); return; } Loading Loading @@ -527,6 +542,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, getPrimitiveDuration, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_COMPOSE_EFFECTS) == 0) { state.SkipWithMessage("compose effects unavailable"); return; } Loading @@ -536,6 +552,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, getPrimitiveDuration, { std::vector<Aidl::CompositePrimitive> supported; mVibrator->getSupportedPrimitives(&supported); if (std::find(supported.begin(), supported.end(), primitive) == supported.end()) { state.SkipWithMessage("supported primitives unavailable"); return; } Loading @@ -548,6 +565,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, compose, { int32_t capabilities = 0; mVibrator->getCapabilities(&capabilities); if ((capabilities & Aidl::IVibrator::CAP_COMPOSE_EFFECTS) == 0) { state.SkipWithMessage("compose effects unavailable"); return; } Loading @@ -559,6 +577,7 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench_Aidl, compose, { std::vector<Aidl::CompositePrimitive> supported; mVibrator->getSupportedPrimitives(&supported); if (std::find(supported.begin(), supported.end(), effect.primitive) == supported.end()) { state.SkipWithMessage("supported primitives unavailable"); return; } Loading