Commit 090449e1 authored by Jarryd's avatar Jarryd Committed by Chromium LUCI CQ

dPWA: Add switch for overriding integration test case.

This makes debugging a test and writing tests a little easier
by allowing developers to run a single test at a time.

 * Add new chrome switch, kWebAppIntegrationTestCase
 * Add new method, GetCommandLineTestOverride()

Bug: 1165832
Change-Id: I739c1fc85b115e77b881fcdab87db06ab01cf074
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2624033
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844099}
parent 08e3ac0b
......@@ -33,7 +33,6 @@
#include "chrome/browser/web_applications/test/web_app_install_observer.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
......@@ -64,6 +63,12 @@ const std::string kPlatformName =
"Win";
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Command-line switch that overrides test case input. Takes a comma
// separated list of testing actions. This aids in development of tests
// by allowing one to run a single test at a time, and avoid running every
// test case in the suite.
const char kWebAppIntegrationTestCase[] = "web-app-integration-test-case";
std::string StripAllWhitespace(std::string line) {
std::string output;
output.reserve(line.size());
......@@ -86,10 +91,24 @@ base::FilePath GetTestFilePath(const std::string& file_name) {
return file_path.AppendASCII(file_name);
}
std::string GetCommandLineTestOverride() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kWebAppIntegrationTestCase)) {
return command_line->GetSwitchValueASCII(kWebAppIntegrationTestCase);
}
return "";
}
std::vector<std::string> ReadTestInputFile(const std::string& file_name) {
std::vector<std::string> test_cases;
std::string command_line_test_case = GetCommandLineTestOverride();
if (!command_line_test_case.empty()) {
test_cases.push_back(StripAllWhitespace(command_line_test_case));
return test_cases;
}
base::FilePath file = GetTestFilePath(file_name);
std::string contents;
std::vector<std::string> test_cases;
if (!base::ReadFileToString(file, &contents)) {
return test_cases;
}
......
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