Commit 40900b55 authored by Jiaquan He's avatar Jiaquan He Committed by Commit Bot

app_list: add TestAppListClient for future tests.

When we have the app list UI in ash, UI behaviors in ash unit tests may
invoke calls into chrome in many cases. We will use this fake client to
consume these calls and limit all activities in ash only.

Bug: 733662
Change-Id: I34361e3b76cac70643540c763e890e3d12865c85
Reviewed-on: https://chromium-review.googlesource.com/952526
Commit-Queue: Jiaquan He <hejq@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541523}
parent e188568b
...@@ -1821,6 +1821,8 @@ static_library("test_support_common") { ...@@ -1821,6 +1821,8 @@ static_library("test_support_common") {
"accessibility/test_accessibility_controller_client.h", "accessibility/test_accessibility_controller_client.h",
"app_list/test/app_list_test_helper.cc", "app_list/test/app_list_test_helper.cc",
"app_list/test/app_list_test_helper.h", "app_list/test/app_list_test_helper.h",
"app_list/test/test_app_list_client.cc",
"app_list/test/test_app_list_client.h",
"app_list/test_app_list_presenter_impl.cc", "app_list/test_app_list_presenter_impl.cc",
"app_list/test_app_list_presenter_impl.h", "app_list/test_app_list_presenter_impl.h",
"display/display_configuration_controller_test_api.cc", "display/display_configuration_controller_test_api.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/app_list/test/test_app_list_client.h"
#include "ash/shell.h"
namespace ash {
TestAppListClient::TestAppListClient() : binding_(this) {}
TestAppListClient::~TestAppListClient() {}
mojom::AppListClientPtr TestAppListClient::CreateInterfacePtrAndBind() {
mojom::AppListClientPtr ptr;
binding_.Bind(mojo::MakeRequest(&ptr));
return ptr;
}
void TestAppListClient::StartVoiceInteractionSession() {
++voice_session_count_;
}
void TestAppListClient::ToggleVoiceInteractionSession() {
++voice_session_count_;
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_APP_LIST_TEST_TEST_APP_LIST_CLIENT_H_
#define ASH_APP_LIST_TEST_TEST_APP_LIST_CLIENT_H_
#include <string>
#include "ash/public/interfaces/app_list.mojom.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace ash {
// A test implementation of AppListClient that records function call counts.
// Registers itself as the presenter for the app list on construction.
class TestAppListClient : public mojom::AppListClient {
public:
TestAppListClient();
~TestAppListClient() override;
mojom::AppListClientPtr CreateInterfacePtrAndBind();
// ash::mojom::AppListClient:
void StartSearch(const base::string16& raw_query) override {}
void OpenSearchResult(const std::string& result_id,
int event_flags) override {}
void InvokeSearchResultAction(const std::string& result_id,
int action_index,
int event_flags) override {}
void ViewClosing() override {}
void ViewShown(int64_t display_id) override {}
void ActivateItem(const std::string& id, int event_flags) override {}
void GetContextMenuModel(const std::string& id,
GetContextMenuModelCallback callback) override {}
void ContextMenuItemSelected(const std::string& id,
int command_id,
int event_flags) override {}
void OnAppListTargetVisibilityChanged(bool visible) override {}
void OnAppListVisibilityChanged(bool visible) override {}
void StartVoiceInteractionSession() override;
void ToggleVoiceInteractionSession() override;
void OnFolderCreated(mojom::AppListItemMetadataPtr item) override {}
void OnFolderDeleted(mojom::AppListItemMetadataPtr item) override {}
void OnItemUpdated(mojom::AppListItemMetadataPtr item) override {}
size_t voice_session_count() const { return voice_session_count_; }
private:
size_t voice_session_count_ = 0u;
mojo::Binding<mojom::AppListClient> binding_;
DISALLOW_COPY_AND_ASSIGN(TestAppListClient);
};
} // namespace ash
#endif // ASH_APP_LIST_TEST_TEST_APP_LIST_CLIENT_H_
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