Commit ae648258 authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

Stop using chromeos::FakeSessionManagerClient in ArcSessionImpl tests

It's no longer necessary as we've introduced our own abstraction
layer, arc::ArcClientAdapter. This CL injects a fake ArcClientAdapter
implementation to the test fixture to simplify the test. That allows
us to remove all usage of chromeos:: and login_manager:: from the
test, and the test no longer depends on the internals of the ARC
container.

BUG=b:143175953
TEST=try

Change-Id: Ia39f492a94b5698794df423b181ff935b944eec4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008284Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733888}
parent a94bda97
...@@ -99,6 +99,7 @@ class ArcSessionDelegateImpl : public ArcSessionImpl::Delegate { ...@@ -99,6 +99,7 @@ class ArcSessionDelegateImpl : public ArcSessionImpl::Delegate {
void GetLcdDensity(GetLcdDensityCallback callback) override; void GetLcdDensity(GetLcdDensityCallback callback) override;
void GetFreeDiskSpace(GetFreeDiskSpaceCallback callback) override; void GetFreeDiskSpace(GetFreeDiskSpaceCallback callback) override;
version_info::Channel GetChannel() override; version_info::Channel GetChannel() override;
std::unique_ptr<ArcClientAdapter> CreateClient() override;
private: private:
// Synchronously create a UNIX domain socket. This is designed to run on a // Synchronously create a UNIX domain socket. This is designed to run on a
...@@ -192,6 +193,10 @@ version_info::Channel ArcSessionDelegateImpl::GetChannel() { ...@@ -192,6 +193,10 @@ version_info::Channel ArcSessionDelegateImpl::GetChannel() {
return channel_; return channel_;
} }
std::unique_ptr<ArcClientAdapter> ArcSessionDelegateImpl::CreateClient() {
return ArcClientAdapter::Create(GetChannel());
}
// static // static
base::ScopedFD ArcSessionDelegateImpl::CreateSocketInternal() { base::ScopedFD ArcSessionDelegateImpl::CreateSocketInternal() {
auto endpoint = mojo::NamedPlatformChannel({kArcBridgeSocketPath}); auto endpoint = mojo::NamedPlatformChannel({kArcBridgeSocketPath});
...@@ -315,7 +320,7 @@ ArcSessionImpl::ArcSessionImpl(std::unique_ptr<Delegate> delegate, ...@@ -315,7 +320,7 @@ ArcSessionImpl::ArcSessionImpl(std::unique_ptr<Delegate> delegate,
chromeos::SchedulerConfigurationManagerBase* chromeos::SchedulerConfigurationManagerBase*
scheduler_configuration_manager) scheduler_configuration_manager)
: delegate_(std::move(delegate)), : delegate_(std::move(delegate)),
client_(ArcClientAdapter::Create(delegate_->GetChannel())), client_(delegate_->CreateClient()),
scheduler_configuration_manager_(scheduler_configuration_manager) { scheduler_configuration_manager_(scheduler_configuration_manager) {
DCHECK(client_); DCHECK(client_);
client_->AddObserver(this); client_->AddObserver(this);
......
...@@ -169,11 +169,14 @@ class ArcSessionImpl ...@@ -169,11 +169,14 @@ class ArcSessionImpl
// Returns the channel for the installation. // Returns the channel for the installation.
virtual version_info::Channel GetChannel() = 0; virtual version_info::Channel GetChannel() = 0;
// Creates and returns a client adapter.
virtual std::unique_ptr<ArcClientAdapter> CreateClient() = 0;
}; };
ArcSessionImpl(std::unique_ptr<Delegate> delegate, ArcSessionImpl(std::unique_ptr<Delegate> delegate,
chromeos::SchedulerConfigurationManagerBase* chromeos::SchedulerConfigurationManagerBase*
scheduler_configuration_manager_); scheduler_configuration_manager);
~ArcSessionImpl() override; ~ArcSessionImpl() override;
// Returns default delegate implementation used for the production. // Returns default delegate implementation used for the production.
...@@ -183,6 +186,7 @@ class ArcSessionImpl ...@@ -183,6 +186,7 @@ class ArcSessionImpl
version_info::Channel channel); version_info::Channel channel);
State GetStateForTesting() { return state_; } State GetStateForTesting() { return state_; }
ArcClientAdapter* GetClientForTesting() { return client_.get(); }
// ArcSession overrides: // ArcSession overrides:
void StartMiniInstance() override; void StartMiniInstance() override;
......
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