| Index: components/arc/test/fake_app_instance.h
|
| diff --git a/components/arc/test/fake_arc_bridge_service.h b/components/arc/test/fake_app_instance.h
|
| similarity index 51%
|
| copy from components/arc/test/fake_arc_bridge_service.h
|
| copy to components/arc/test/fake_app_instance.h
|
| index 0d2bb07e880c19320fc4c01dbd5c8bd9fd814feb..267e1be8f20d21324d52f8a9e7ed6e2602074a0a 100644
|
| --- a/components/arc/test/fake_arc_bridge_service.h
|
| +++ b/components/arc/test/fake_app_instance.h
|
| @@ -2,29 +2,25 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
|
| -#define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
|
| +#ifndef COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_
|
| +#define COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_
|
|
|
| #include <string>
|
| #include <vector>
|
|
|
| -#include "base/macros.h"
|
| #include "base/memory/scoped_vector.h"
|
| -#include "components/arc/arc_bridge_service.h"
|
| +#include "components/arc/common/app.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
|
|
| namespace arc {
|
|
|
| -class FakeArcBridgeService : public ArcBridgeService {
|
| +class FakeAppInstance : public AppInstance {
|
| public:
|
| class Request {
|
| public:
|
| Request(const std::string& package, const std::string& activity)
|
| - : package_(package),
|
| - activity_(activity) {
|
| - }
|
| -
|
| - ~Request() {
|
| - }
|
| + : package_(package), activity_(activity) {}
|
| + ~Request() {}
|
|
|
| const std::string& package() const { return package_; }
|
|
|
| @@ -46,12 +42,8 @@ class FakeArcBridgeService : public ArcBridgeService {
|
| IconRequest(const std::string& package,
|
| const std::string& activity,
|
| ScaleFactor scale_factor)
|
| - : Request(package, activity),
|
| - scale_factor_(scale_factor) {
|
| - }
|
| -
|
| - ~IconRequest() {
|
| - }
|
| + : Request(package, activity), scale_factor_(scale_factor) {}
|
| + ~IconRequest() {}
|
|
|
| int scale_factor() const { return scale_factor_; }
|
|
|
| @@ -61,29 +53,27 @@ class FakeArcBridgeService : public ArcBridgeService {
|
| DISALLOW_COPY_AND_ASSIGN(IconRequest);
|
| };
|
|
|
| - FakeArcBridgeService();
|
| - ~FakeArcBridgeService() override;
|
| -
|
| - // arc::ArcBridgeService
|
| - void DetectAvailability() override;
|
| - void HandleStartup() override;
|
| - void Shutdown() override;
|
| - bool RegisterInputDevice(const std::string& name,
|
| - const std::string& device_type,
|
| - base::ScopedFD fd) override;
|
| - bool SendBroadcast(const std::string& action,
|
| - const std::string& package,
|
| - const std::string& clazz,
|
| - const base::DictionaryValue& extras) override;
|
| - bool RefreshAppList() override;
|
| - bool LaunchApp(const std::string& package,
|
| - const std::string& activity) override;
|
| - bool RequestAppIcon(const std::string& package,
|
| - const std::string& activity,
|
| + explicit FakeAppInstance(AppHost* app_host);
|
| + ~FakeAppInstance() override;
|
| +
|
| + void Bind(mojo::InterfaceRequest<AppInstance> interface_request) {
|
| + binding_.Bind(std::move(interface_request));
|
| + }
|
| +
|
| + // AppInstance overrides:
|
| + void Init(AppHostPtr host_ptr) override {}
|
| + void RefreshAppList() override;
|
| + void LaunchApp(const mojo::String& package,
|
| + const mojo::String& activity) override;
|
| + void RequestAppIcon(const mojo::String& package,
|
| + const mojo::String& activity,
|
| ScaleFactor scale_factor) override;
|
| - bool SendNotificationEventToAndroid(const std::string& key,
|
| - ArcNotificationEvent event) override;
|
| - bool RequestProcessList() override;
|
| +
|
| + // Methods to reply messages.
|
| + void SendRefreshAppList(const std::vector<AppInfo>& apps);
|
| + bool GenerateAndSendIcon(const AppInfo& app,
|
| + ScaleFactor scale_factor,
|
| + std::string* png_data_as_string);
|
|
|
| int refresh_app_list_count() const { return refresh_app_list_count_; }
|
|
|
| @@ -95,30 +85,29 @@ class FakeArcBridgeService : public ArcBridgeService {
|
| return icon_requests_;
|
| }
|
|
|
| - void SetReady();
|
| -
|
| - void SetStopped();
|
| -
|
| - bool HasObserver(const Observer* observer);
|
| - bool HasAppObserver(const AppObserver* observer);
|
| + // This method can be called on tests when a method is intended to
|
| + // be called across a Mojo proxy.
|
| + void WaitForIncomingMethodCall();
|
|
|
| - void SendRefreshAppList(const std::vector<AppInfo>& apps);
|
| -
|
| - bool GenerateAndSendIcon(const AppInfo& app,
|
| - ScaleFactor scale_factor,
|
| - std::string* png_data);
|
| + // As part of the initialization process, the instance side calls
|
| + // AppHost::OnAppInstanceReady(), which in turn calls AppInstance::Init() and
|
| + // AppInstance::RefreshAppList(). This method should be called after a call
|
| + // to ArcBridgeHost::OnAppInstanceReady() to make sure all method calls have
|
| + // been dispatched.
|
| + void WaitForOnAppInstanceReady();
|
|
|
| private:
|
| + // Mojo endpoints.
|
| + mojo::Binding<AppInstance> binding_;
|
| + AppHost* app_host_;
|
| // Number of RefreshAppList calls.
|
| int refresh_app_list_count_ = 0;
|
| // Keeps information about launch requests.
|
| ScopedVector<Request> launch_requests_;
|
| // Keeps information about icon load requests.
|
| ScopedVector<IconRequest> icon_requests_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService);
|
| };
|
|
|
| } // namespace arc
|
|
|
| -#endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
|
| +#endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_
|
|
|