Commit df8a701c authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

Reland "Add a new test case for |AssistantManagerServiceImpl|."

This is a reland of 64cf44e2

Original change's description:
> Add a new test case for |AssistantManagerServiceImpl|.
> 
> This CL adds a new test case to ensure we update the supported action
> list stored in |AssistantManagerServiceImpl| when ambient mode state has
> changed.
> 
> Bug: b/149237062
> Test: run the new unit test added in this change.
> 
> Change-Id: Idc3c538e023cb59e76fb6c71219e4846da6d9c30
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969777
> Commit-Queue: Meilin Wang <meilinw@chromium.org>
> Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#740817}

Bug: b/149237062
Change-Id: I56f942df9293808a2411272022fe3cf3923096f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053287Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741170}
parent 79ddeccd
......@@ -314,9 +314,6 @@ void AssistantManagerServiceImpl::SetAccessToken(
}
void AssistantManagerServiceImpl::EnableAmbientMode(bool enabled) {
if (!assistant_manager_)
return;
// Update |action_module_| accordingly, as some actions, e.g. open URL
// in the browser, are not supported in ambient mode.
action_module_->SetAmbientModeEnabled(enabled);
......@@ -460,6 +457,8 @@ void AssistantManagerServiceImpl::SyncDeviceAppsStatus() {
}
void AssistantManagerServiceImpl::StartVoiceInteraction() {
DCHECK(assistant_manager_);
platform_api_->SetMicState(true);
assistant_manager_->StartAssistantInteraction();
}
......@@ -479,7 +478,7 @@ void AssistantManagerServiceImpl::StopActiveInteraction(
void AssistantManagerServiceImpl::StartWarmerWelcomeInteraction(
int num_warmer_welcome_triggered,
bool allow_tts) {
DCHECK(assistant_manager_internal_ != nullptr);
DCHECK(assistant_manager_internal_);
const std::string interaction =
CreateWarmerWelcomeInteraction(num_warmer_welcome_triggered);
......
......@@ -235,6 +235,11 @@ class COMPONENT_EXPORT(ASSISTANT_SERVICE) AssistantManagerServiceImpl
// thread is finished.
void WaitUntilStartIsFinishedForTesting();
// Get the action module for testing.
action::CrosActionModule* action_module_for_testing() {
return action_module_.get();
}
private:
class AssistantMediaSessionObserver;
void StartAssistantInternal(const base::Optional<std::string>& access_token);
......
......@@ -221,6 +221,10 @@ class AssistantManagerServiceImplTest : public testing::Test {
return delegate_->assistant_manager_internal();
}
action::CrosActionModule* action_module() {
return assistant_manager_service_->action_module_for_testing();
}
void Start() {
assistant_manager_service()->Start("dummy-access-token",
/*enable_hotword=*/false);
......@@ -542,5 +546,16 @@ TEST_F(AssistantManagerServiceImplTest,
Start();
}
TEST_F(AssistantManagerServiceImplTest,
ShouldUpdateActionModuleWhenAmbientModeStateChanged) {
EXPECT_FALSE(action_module()->IsAmbientModeEnabledForTesting());
assistant_manager_service()->EnableAmbientMode(true);
EXPECT_TRUE(action_module()->IsAmbientModeEnabledForTesting());
assistant_manager_service()->EnableAmbientMode(false);
EXPECT_FALSE(action_module()->IsAmbientModeEnabledForTesting());
}
} // namespace assistant
} // namespace chromeos
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