Don't return bookmark results if an empty or space-only query is specified
[chromium-blink-merge.git] / testing / android / native_test_util.cc
blob7d5f02539738da400fe578ef006494f824a02bf0
1 // Copyright (c) 2013 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.
5 #include "testing/android/native_test_util.h"
7 #include "base/file_util.h"
8 #include "base/files/file_path.h"
9 #include "base/strings/string_tokenizer.h"
10 #include "base/strings/string_util.h"
12 namespace {
14 void ParseArgsFromString(const std::string& command_line,
15 std::vector<std::string>* args) {
16 base::StringTokenizer tokenizer(command_line, base::kWhitespaceASCII);
17 tokenizer.set_quote_chars("\"");
18 while (tokenizer.GetNext()) {
19 std::string token;
20 base::RemoveChars(tokenizer.token(), "\"", &token);
21 args->push_back(token);
25 } // namespace
27 namespace testing {
28 namespace native_test_util {
30 void ParseArgsFromCommandLineFile(
31 const char* path, std::vector<std::string>* args) {
32 base::FilePath command_line(path);
33 std::string command_line_string;
34 if (base::ReadFileToString(command_line, &command_line_string)) {
35 ParseArgsFromString(command_line_string, args);
39 int ArgsToArgv(const std::vector<std::string>& args,
40 std::vector<char*>* argv) {
41 // We need to pass in a non-const char**.
42 int argc = args.size();
44 argv->resize(argc + 1);
45 for (int i = 0; i < argc; ++i) {
46 (*argv)[i] = const_cast<char*>(args[i].c_str());
48 (*argv)[argc] = NULL; // argv must be NULL terminated.
50 return argc;
53 } // namespace native_test_util
54 } // namespace testing