Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3317)

Unified Diff: blimp/common/fake_commandline.cc

Issue 1958033003: Allows client to access auth token from command line specified file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698