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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/common/fake_commandline.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/command_line.h"
11 #include "base/files/file_util.h"
12 #include "base/strings/stringprintf.h"
13 #include "blimp/engine/app/switches.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace blimp {
17
18 void CreateFileForSwitch(const std::string& filepath_switch,
19 const std::string& data) {
20 ASSERT_TRUE(base::WriteFile(GetFilepathForSwitch(filepath_switch),
21 data.c_str(), data.size()));
22 }
23
24 void RemoveFileForSwitch(const std::string& filepath_switch) {
25 base::DeleteFile(GetFilepathForSwitch(filepath_switch), false);
26 }
27
28 base::CommandLine CreateCommandLine(
29 const std::vector<std::string>& filepath_switches) {
30 base::CommandLine::StringVector cmd_vec = {"dummy_program"};
31 for (const std::string& filepath_switch : filepath_switches) {
32 cmd_vec.push_back(base::StringPrintf(
33 "--%s=%s", filepath_switch.c_str(),
34 GetFilepathForSwitch(filepath_switch).AsUTF8Unsafe().c_str()));
35 }
36 return base::CommandLine(cmd_vec);
37 }
38
39 base::FilePath GetFilepathForSwitch(
40 const std::string& filepath_switch) {
41 return temp_dir_.path().Append(filepath_switch);
42 }
43 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698