From 201ffea4a91f1ff052bb72eedb44a3bff2a35c76 Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Thu, 31 Oct 2019 14:58:03 +0000 Subject: Add tests for GreylistMaxQ. Test: mma test-art-host-gtest-hidden_api_test64 Bug: 133832325 Change-Id: I1a91bcea501325fd4e79e25db1ed0be6e1028b49 --- runtime/hidden_api_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'runtime/hidden_api_test.cc') diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc index 70fafe6587..d5c03c3850 100644 --- a/runtime/hidden_api_test.cc +++ b/runtime/hidden_api_test.cc @@ -109,6 +109,7 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kJustWarn); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxQ()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), false); @@ -118,6 +119,7 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { static_cast(hiddenapi::ApiList::GreylistMaxO().GetMaxAllowedSdkVersion())); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxQ()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); @@ -127,6 +129,7 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { static_cast(hiddenapi::ApiList::GreylistMaxO().GetMaxAllowedSdkVersion()) + 1); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxQ()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), true); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); @@ -136,6 +139,17 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { static_cast(hiddenapi::ApiList::GreylistMaxP().GetMaxAllowedSdkVersion()) + 1); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxQ()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), true); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), true); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); + + runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled); + runtime_->SetTargetSdkVersion( + static_cast(hiddenapi::ApiList::GreylistMaxQ().GetMaxAllowedSdkVersion()) + 1); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxQ()), true); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), true); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), true); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); -- cgit v1.2.3-59-g8ed1b