Commit 924c7bd1 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Cleanup cast_runner_integration_tests

Moved common code to helper function to reduce code duplication.

Change-Id: I5a9eb369e70e2fcf3ef520004089ece479935654
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092950
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749377}
parent 847ce08f
...@@ -14,10 +14,31 @@ const char kAgentComponentUrl[] = ...@@ -14,10 +14,31 @@ const char kAgentComponentUrl[] =
"fuchsia-pkg://fuchsia.com/cast_agent#meta/cast_agent.cmx"; "fuchsia-pkg://fuchsia.com/cast_agent#meta/cast_agent.cmx";
} // namespace } // namespace
FakeApplicationConfigManager::FakeApplicationConfigManager() = default; // static
chromium::cast::ApplicationConfig FakeApplicationConfigManager::CreateConfig(
const std::string& id,
const GURL& url) {
chromium::cast::ApplicationConfig app_config;
app_config.set_id(id);
app_config.set_display_name("Dummy test app");
app_config.set_web_url(url.spec());
app_config.set_agent_url(kAgentComponentUrl);
return app_config;
}
FakeApplicationConfigManager::FakeApplicationConfigManager() = default;
FakeApplicationConfigManager::~FakeApplicationConfigManager() = default; FakeApplicationConfigManager::~FakeApplicationConfigManager() = default;
void FakeApplicationConfigManager::AddAppConfig(
chromium::cast::ApplicationConfig app_config) {
id_to_config_[app_config.id()] = std::move(app_config);
}
void FakeApplicationConfigManager::AddApp(const std::string& id,
const GURL& url) {
AddAppConfig(CreateConfig(id, url));
}
void FakeApplicationConfigManager::GetConfig(std::string id, void FakeApplicationConfigManager::GetConfig(std::string id,
GetConfigCallback callback) { GetConfigCallback callback) {
if (id_to_config_.find(id) == id_to_config_.end()) { if (id_to_config_.find(id) == id_to_config_.end()) {
...@@ -29,40 +50,3 @@ void FakeApplicationConfigManager::GetConfig(std::string id, ...@@ -29,40 +50,3 @@ void FakeApplicationConfigManager::GetConfig(std::string id,
callback(std::move(std::move(id_to_config_[id]))); callback(std::move(std::move(id_to_config_[id])));
id_to_config_.erase(id); id_to_config_.erase(id);
} }
void FakeApplicationConfigManager::AddAppMapping(const std::string& id,
const GURL& url,
bool enable_remote_debugging) {
AddAppMappingWithAgent(id, url, enable_remote_debugging, kAgentComponentUrl);
}
void FakeApplicationConfigManager::AddAppMappingWithAgent(
const std::string& id,
const GURL& url,
bool enable_remote_debugging,
const std::string& agent_url) {
chromium::cast::ApplicationConfig app_config;
app_config.set_id(id);
app_config.set_display_name("Dummy test app");
app_config.set_web_url(url.spec());
app_config.set_enable_remote_debugging(enable_remote_debugging);
app_config.set_agent_url(agent_url);
id_to_config_[id] = std::move(app_config);
}
void FakeApplicationConfigManager::AddAppMappingWithContentDirectories(
const std::string& id,
const GURL& url,
std::vector<fuchsia::web::ContentDirectoryProvider> directories) {
chromium::cast::ApplicationConfig app_config;
app_config.set_id(id);
app_config.set_display_name("Dummy test app");
app_config.set_web_url(url.spec());
app_config.set_agent_url(kAgentComponentUrl);
if (!directories.empty()) {
app_config.set_content_directories_for_isolated_application(
std::move(directories));
}
id_to_config_[id] = std::move(app_config);
}
...@@ -21,25 +21,17 @@ class FakeApplicationConfigManager ...@@ -21,25 +21,17 @@ class FakeApplicationConfigManager
FakeApplicationConfigManager(); FakeApplicationConfigManager();
~FakeApplicationConfigManager() override; ~FakeApplicationConfigManager() override;
// Associates a Cast application |id| with a url, to be served from the // Creates a config for a dummy application with the specified |id| and |url|.
// EmbeddedTestServer. // Callers should updated the returned config as necessary and then register
void AddAppMapping(const std::string& id, // the app by calling AddAppConfig().
const GURL& url, static chromium::cast::ApplicationConfig CreateConfig(const std::string& id,
bool enable_remote_debugging); const GURL& url);
// Associates a Cast application |id| with a url and an agent that handles // Adds |app_config| to the list of apps.
// its bindings, to be served from the EmbeddedTestServer. void AddAppConfig(chromium::cast::ApplicationConfig app_config);
void AddAppMappingWithAgent(const std::string& id,
const GURL& url, // Associates a Cast application |id| with the |url|.
bool enable_remote_debugging, void AddApp(const std::string& id, const GURL& url);
const std::string& agent_url);
// Associates a Cast application |id| with a url and a set of content
// directories, to be served from the EmbeddedTestServer.
void AddAppMappingWithContentDirectories(
const std::string& id,
const GURL& url,
std::vector<fuchsia::web::ContentDirectoryProvider> directories);
// chromium::cast::ApplicationConfigManager interface. // chromium::cast::ApplicationConfigManager interface.
void GetConfig(std::string id, GetConfigCallback config_callback) override; void GetConfig(std::string id, GetConfigCallback config_callback) 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