Commit 4336e213 authored by Markus Heintz's avatar Markus Heintz Committed by Commit Bot

[User Consent] Implement RecordAssistantActivityControlConsent

Bug: 867919
Change-Id: I39368fd24237987d59d6ce6b8102fd67b3856e1f
Reviewed-on: https://chromium-review.googlesource.com/1190762Reviewed-by: default avatarYue Li <updowndota@chromium.org>
Reviewed-by: default avatarvitaliii <vitaliii@chromium.org>
Commit-Queue: Markus Heintz <markusheintz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586663}
parent dfc32c00
...@@ -299,6 +299,24 @@ void ConsentAuditorImpl::RecordUnifiedConsent( ...@@ -299,6 +299,24 @@ void ConsentAuditorImpl::RecordUnifiedConsent(
void ConsentAuditorImpl::RecordAssistantActivityControlConsent( void ConsentAuditorImpl::RecordAssistantActivityControlConsent(
const std::string& account_id, const std::string& account_id,
const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent) { const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent) {
// TODO(markusheintz): Turn this into a DCHECK once the fallback is not
// needed.
if (IsSeparateConsentTypeEnabled()) {
std::unique_ptr<sync_pb::UserConsentSpecifics> specifics =
std::make_unique<sync_pb::UserConsentSpecifics>();
specifics->set_account_id(account_id);
specifics->set_client_consent_time_usec(
clock_->Now().since_origin().InMicroseconds());
specifics->set_locale(app_locale_);
sync_pb::UserConsentTypes::AssistantActivityControlConsent*
assistant_consent =
specifics->mutable_assistant_activity_control_consent();
assistant_consent->CopyFrom(consent);
consent_sync_bridge_->RecordConsent(std::move(specifics));
} else {
// TODO(markusheintz): Implement the fallback.
}
} }
void ConsentAuditorImpl::RecordLocalConsent( void ConsentAuditorImpl::RecordLocalConsent(
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
using ArcPlayTermsOfServiceConsent = using ArcPlayTermsOfServiceConsent =
sync_pb::UserConsentTypes::ArcPlayTermsOfServiceConsent; sync_pb::UserConsentTypes::ArcPlayTermsOfServiceConsent;
using AssistantActivityControlConsent =
sync_pb::UserConsentTypes::AssistantActivityControlConsent;
using SyncConsent = sync_pb::UserConsentTypes::SyncConsent; using SyncConsent = sync_pb::UserConsentTypes::SyncConsent;
using sync_pb::UserConsentSpecifics; using sync_pb::UserConsentSpecifics;
using sync_pb::UserEventSpecifics; using sync_pb::UserEventSpecifics;
...@@ -499,4 +501,42 @@ TEST_F(ConsentAuditorImplTest, ShouldReturnSyncDelegateWhenBridgePresent) { ...@@ -499,4 +501,42 @@ TEST_F(ConsentAuditorImplTest, ShouldReturnSyncDelegateWhenBridgePresent) {
consent_auditor()->GetControllerDelegate().get()); consent_auditor()->GetControllerDelegate().get());
} }
TEST_F(ConsentAuditorImplTest, RecordAssistantActivityControlConsent) {
SetIsSeparateConsentTypeEnabledFeature(true);
auto wrapped_fake_bridge = std::make_unique<FakeConsentSyncBridge>();
FakeConsentSyncBridge* fake_bridge = wrapped_fake_bridge.get();
base::SimpleTestClock test_clock;
SetConsentSyncBridge(std::move(wrapped_fake_bridge));
SetUserEventService(nullptr);
SetAppVersion(kCurrentAppVersion);
SetAppLocale(kCurrentAppLocale);
SetClock(&test_clock);
BuildConsentAuditorImpl();
AssistantActivityControlConsent assistant_consent;
assistant_consent.set_status(UserConsentTypes::GIVEN);
const char ui_audit_key[] = {0x67, 0x23, 0x78};
assistant_consent.set_ui_audit_key(std::string(ui_audit_key, 3));
consent_auditor()->RecordAssistantActivityControlConsent(kAccountId,
assistant_consent);
std::vector<UserConsentSpecifics> consents =
fake_bridge->GetRecordedUserConsents();
ASSERT_EQ(1U, consents.size());
UserConsentSpecifics consent = consents[0];
EXPECT_EQ(kAccountId, consent.account_id());
EXPECT_EQ(kCurrentAppLocale, consent.locale());
EXPECT_EQ(true, consent.has_assistant_activity_control_consent());
EXPECT_EQ(UserConsentTypes::GIVEN,
consent.assistant_activity_control_consent().status());
EXPECT_EQ(std::string(ui_audit_key, 3),
consent.assistant_activity_control_consent().ui_audit_key());
}
} // namespace consent_auditor } // namespace consent_auditor
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment