| Index: blimp/common/fake_commandline.cc
|
| diff --git a/blimp/common/fake_commandline.cc b/blimp/common/fake_commandline.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..24f98f0ba48f953521bd2bc47dc37fd22d303340
|
| --- /dev/null
|
| +++ b/blimp/common/fake_commandline.cc
|
| @@ -0,0 +1,43 @@
|
| +// Copyright 2016 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 "blimp/common/fake_commandline.h"
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/files/file_util.h"
|
| +#include "base/strings/stringprintf.h"
|
| +#include "blimp/engine/app/switches.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace blimp {
|
| +
|
| +void CreateFileForSwitch(const std::string& filepath_switch,
|
| + const std::string& data) {
|
| + ASSERT_TRUE(base::WriteFile(GetFilepathForSwitch(filepath_switch),
|
| + data.c_str(), data.size()));
|
| +}
|
| +
|
| +void RemoveFileForSwitch(const std::string& filepath_switch) {
|
| + base::DeleteFile(GetFilepathForSwitch(filepath_switch), false);
|
| +}
|
| +
|
| +base::CommandLine CreateCommandLine(
|
| + const std::vector<std::string>& filepath_switches) {
|
| + base::CommandLine::StringVector cmd_vec = {"dummy_program"};
|
| + for (const std::string& filepath_switch : filepath_switches) {
|
| + cmd_vec.push_back(base::StringPrintf(
|
| + "--%s=%s", filepath_switch.c_str(),
|
| + GetFilepathForSwitch(filepath_switch).AsUTF8Unsafe().c_str()));
|
| + }
|
| + return base::CommandLine(cmd_vec);
|
| +}
|
| +
|
| +base::FilePath GetFilepathForSwitch(
|
| + const std::string& filepath_switch) {
|
| + return temp_dir_.path().Append(filepath_switch);
|
| +}
|
| +} // namespace blimp
|
|
|