summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-15 00:18:30 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-15 00:18:30 +0000
commit9d84e1a1e1d17ab3d64757c0a82f7f95a0aae293 (patch)
treef70d6b45b28c268a03006d0859086d9649e4f0d2 /base
parent12c0b1823a10d2b0cf63144bcd32b556c73177af (diff)
downloadchromium_src-9d84e1a1e1d17ab3d64757c0a82f7f95a0aae293.zip
chromium_src-9d84e1a1e1d17ab3d64757c0a82f7f95a0aae293.tar.gz
chromium_src-9d84e1a1e1d17ab3d64757c0a82f7f95a0aae293.tar.bz2
Revert 66088 - Changing the installer switches from wchar_t[] to char[].
Because of this I'm also refactoring some code that before was using wstring to build command lines by hand instead of using the CommandLine class. Now we use CommandLine. To get this to work correctly, I also needed to fix CommandLine::AppendArguments so I added a little test for it. TEST=There should be no changes in functionality. Run all installer tests. BUG=61609 Review URL: http://codereview.chromium.org/4928002 TBR=tommi@chromium.org Review URL: http://codereview.chromium.org/4988001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/command_line.cc19
-rw-r--r--base/command_line_unittest.cc27
2 files changed, 4 insertions, 42 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index b335e7c..3308e80 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -431,14 +431,7 @@ void CommandLine::AppendArguments(const CommandLine& other,
// Verify include_program is used correctly.
// Logic could be shorter but this is clearer.
DCHECK_EQ(include_program, !other.GetProgram().empty());
- if (include_program)
- program_ = other.program_;
-
- if (!command_line_string_.empty())
- command_line_string_ += L' ';
-
- command_line_string_ += other.command_line_string_;
-
+ command_line_string_ += L" " + other.command_line_string_;
std::map<std::string, StringType>::const_iterator i;
for (i = other.switches_.begin(); i != other.switches_.end(); ++i)
switches_[i->first] = i->second;
@@ -489,15 +482,9 @@ void CommandLine::AppendArguments(const CommandLine& other,
// Verify include_program is used correctly.
// Logic could be shorter but this is clearer.
DCHECK_EQ(include_program, !other.GetProgram().empty());
-
- if (include_program)
- argv_[0] = other.argv_[0];
-
- // Skip the first arg when copying since it's the program but push all
- // arguments to our arg vector.
- for (size_t i = 1; i < other.argv_.size(); ++i)
+ size_t first_arg = include_program ? 0 : 1;
+ for (size_t i = first_arg; i < other.argv_.size(); ++i)
argv_.push_back(other.argv_[i]);
-
std::map<std::string, StringType>::const_iterator i;
for (i = other.switches_.begin(); i != other.switches_.end(); ++i)
switches_[i->first] = i->second;
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 5c525ae..9184aa3 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -5,8 +5,8 @@
#include <string>
#include <vector>
-#include "base/basictypes.h"
#include "base/command_line.h"
+#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -154,28 +154,3 @@ TEST(CommandLineTest, AppendSwitches) {
cl.command_line_string());
#endif
}
-
-// Tests that when AppendArguments is called that the program is set correctly
-// on the target CommandLine object and the switches from the source
-// CommandLine are added to the target.
-TEST(CommandLineTest, AppendArguments) {
- CommandLine cl1(FilePath(FILE_PATH_LITERAL("Program")));
- cl1.AppendSwitch("switch1");
- cl1.AppendSwitchASCII("switch2", "foo");
-
- CommandLine cl2(CommandLine::NO_PROGRAM);
- cl2.AppendArguments(cl1, true);
- EXPECT_EQ(cl1.GetProgram().value(), cl2.GetProgram().value());
- EXPECT_EQ(cl1.command_line_string(), cl2.command_line_string());
-
- CommandLine c1(FilePath(FILE_PATH_LITERAL("Program1")));
- c1.AppendSwitch("switch1");
- CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2")));
- c2.AppendSwitch("switch2");
-
- c1.AppendArguments(c2, true);
- EXPECT_EQ(c1.GetProgram().value(), c2.GetProgram().value());
- EXPECT_TRUE(c1.HasSwitch("switch1"));
- EXPECT_TRUE(c1.HasSwitch("switch2"));
-}
-