Commit 4b80649d authored by Polina Bondarenko's avatar Polina Bondarenko Committed by Commit Bot

wilco_dtc_supportd: start mojo bridge if enabled

WilcoDtcSupportdBridge should be started regardless of the result of
Wilco DTC upstart job, since if the wilco DTC was already running, the
job returns an error.

BUG=b:132311683
TEST=local device

Change-Id: I2f697ee4ae600ffc7d2b33c6cd90ffd8d8ab9121
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1602723Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Polina Bondarenko <pbond@chromium.org>
Auto-Submit: Polina Bondarenko <pbond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658532}
parent ad33818a
......@@ -161,11 +161,14 @@ void WilcoDtcSupportdManager::StopWilcoDtc(WilcoDtcCallback callback) {
}
void WilcoDtcSupportdManager::OnStartWilcoDtc(bool success) {
if (!success) {
DLOG(ERROR) << "Failed to start the wilco DTC";
} else {
if (!success)
DLOG(ERROR) << "Failed to start the wilco DTC, it might be already running";
else
VLOG(1) << "Wilco DTC started";
if (!wilco_dtc_supportd_bridge_)
// The bridge has to be created regardless of a |success| value. When wilco
// DTC is already running, it responds with an error on attempt to start it.
if (!wilco_dtc_supportd_bridge_) {
wilco_dtc_supportd_bridge_ = delegate_->CreateWilcoDtcSupportdBridge();
DCHECK(wilco_dtc_supportd_bridge_);
......
......@@ -38,12 +38,18 @@ class TestUpstartClient final : public FakeUpstartClient {
// FakeUpstartClient overrides:
void StartWilcoDtcService(
chromeos::VoidDBusMethodCallback callback) override {
std::move(callback).Run(true /* success */);
std::move(callback).Run(result_);
}
void StopWilcoDtcService(chromeos::VoidDBusMethodCallback callback) override {
std::move(callback).Run(true /* success */);
std::move(callback).Run(result_);
}
// Sets the result to be passed into callbacks.
void set_result(bool result) { result_ = result; }
private:
bool result_ = true;
};
class MockMojoWilcoDtcSupportdService
......@@ -118,6 +124,10 @@ class WilcoDtcSupportdManagerTest : public testing::Test {
return &mojo_wilco_dtc_supportd_service_;
}
void SetUpstartClientResult(bool result) {
upstart_client_->set_result(result);
}
private:
base::MessageLoop message_loop_;
ScopedTestingCrosSettings scoped_testing_cros_settings_;
......@@ -240,6 +250,16 @@ TEST_F(WilcoDtcSupportdManagerTest, ConfigurationData) {
}
}
// Test that Mojo bridge has been started even if the wilco DTC support
// services were already running.
TEST_F(WilcoDtcSupportdManagerTest, RunningUpstartJob) {
SetWilcoDtcAllowedPolicy(true);
SetUpstartClientResult(false);
WilcoDtcSupportdManager wilco_dtc_supportd_manager(CreateDelegate());
EXPECT_TRUE(WilcoDtcSupportdBridge::Get());
}
} // namespace
} // 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