Commit e7e4a27a authored by Daniel's avatar Daniel Committed by Commit Bot

borealis: Fixing cancelling in the installer

Fixes were added to the Plugin VM installer, which the Borealis
installer is based on. The issue it faced (installation wasn't being
cancelled when the installer window was being closed by the 'X') also
affects the Borealis installer. I've added a fix for it and also
fixed up a problem where cancelling the dialog and repopening it would
break the installation process.

Plugin VM fixes: CL:2462897

Tests: Wrote test and ran other unit tests
Bug: b/171672034

Change-Id: If8f17fd157a96d32cb1bc014ec937149a900ebed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2467306
Commit-Queue: Daniel Ng <danielng@google.com>
Reviewed-by: default avatarNic Hollingum <hollingum@google.com>
Cr-Commit-Position: refs/heads/master@{#820673}
parent 11bdd37a
......@@ -46,7 +46,9 @@ void BorealisInstallerImpl::Start() {
}
void BorealisInstallerImpl::Cancel() {
state_ = State::kCancelling;
if (state_ != State::kIdle) {
state_ = State::kCancelling;
}
for (auto& observer : observers_) {
observer.OnCancelInitiated();
}
......
......@@ -196,6 +196,33 @@ TEST_F(BorealisInstallerTest, InstallationInProgess) {
BorealisService::GetForProfile(profile_.get())->Features().IsEnabled());
}
TEST_F(BorealisInstallerTest, CancelledThenSuccessfulInstallation) {
feature_list_.InitAndEnableFeature(features::kBorealis);
fake_dlcservice_client_->set_install_error(dlcservice::kErrorNone);
EXPECT_CALL(*observer_, OnCancelInitiated());
installer_->Cancel();
task_environment_.RunUntilIdle();
UpdateCurrentDlcs();
ASSERT_EQ(current_dlcs_.dlc_infos_size(), 0);
EXPECT_FALSE(
BorealisService::GetForProfile(profile_.get())->Features().IsEnabled());
ExpectObserverEventsUntil(InstallingState::kInstallingDlc);
EXPECT_CALL(*observer_, OnInstallationEnded(InstallationResult::kCompleted));
installer_->Start();
task_environment_.RunUntilIdle();
UpdateCurrentDlcs();
ASSERT_EQ(current_dlcs_.dlc_infos_size(), 1);
EXPECT_EQ(current_dlcs_.dlc_infos(0).id(), borealis::kBorealisDlcName);
EXPECT_TRUE(
BorealisService::GetForProfile(profile_.get())->Features().IsEnabled());
}
// Note that we don't check if the DLC has/hasn't been installed, since the
// mocked DLC service will always suceeed, so we only care about how the error
// code returned by the service is handled by the installer.
......
......@@ -166,6 +166,9 @@ BorealisInstallerView::BorealisInstallerView(Profile* profile)
BorealisInstallerView::~BorealisInstallerView() {
borealis_installer_->RemoveObserver(this);
if (state_ == State::kConfirmInstall || state_ == State::kInstalling) {
borealis_installer_->Cancel();
}
g_borealis_installer_view = nullptr;
}
......@@ -203,10 +206,6 @@ bool BorealisInstallerView::Accept() {
}
bool BorealisInstallerView::Cancel() {
if (state_ == State::kConfirmInstall || state_ == State::kInstalling) {
borealis_installer_->Cancel();
}
return true;
}
......
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