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

Side by Side Diff: chrome/test/chromedriver/chrome_launcher_unittest.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base64.h" 5 #include "base/base64.h"
6 #include "base/base_paths.h" 6 #include "base/base_paths.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 base::ScopedTempDir extension_dir; 43 base::ScopedTempDir extension_dir;
44 ASSERT_TRUE(extension_dir.CreateUniqueTempDir()); 44 ASSERT_TRUE(extension_dir.CreateUniqueTempDir());
45 45
46 CommandLine command(CommandLine::NO_PROGRAM); 46 CommandLine command(CommandLine::NO_PROGRAM);
47 Status status = internal::ProcessExtensions(extensions, extension_dir.path(), 47 Status status = internal::ProcessExtensions(extensions, extension_dir.path(),
48 false, &command); 48 false, &command);
49 ASSERT_TRUE(status.IsOk()); 49 ASSERT_TRUE(status.IsOk());
50 ASSERT_TRUE(command.HasSwitch("load-extension")); 50 ASSERT_TRUE(command.HasSwitch("load-extension"));
51 base::FilePath temp_ext_path = command.GetSwitchValuePath("load-extension"); 51 base::FilePath temp_ext_path = command.GetSwitchValuePath("load-extension");
52 ASSERT_TRUE(file_util::PathExists(temp_ext_path)); 52 ASSERT_TRUE(base::PathExists(temp_ext_path));
53 } 53 }
54 54
55 TEST(ProcessExtensions, MultipleExtensions) { 55 TEST(ProcessExtensions, MultipleExtensions) {
56 base::FilePath source_root; 56 base::FilePath source_root;
57 PathService::Get(base::DIR_SOURCE_ROOT, &source_root); 57 PathService::Get(base::DIR_SOURCE_ROOT, &source_root);
58 base::FilePath test_ext_path = source_root.AppendASCII( 58 base::FilePath test_ext_path = source_root.AppendASCII(
59 "chrome/test/data/chromedriver"); 59 "chrome/test/data/chromedriver");
60 base::FilePath test_crx_1 = test_ext_path.AppendASCII("ext_test_1.crx"); 60 base::FilePath test_crx_1 = test_ext_path.AppendASCII("ext_test_1.crx");
61 base::FilePath test_crx_2 = test_ext_path.AppendASCII("ext_test_2.crx"); 61 base::FilePath test_crx_2 = test_ext_path.AppendASCII("ext_test_2.crx");
62 62
(...skipping 14 matching lines...) Expand all
77 CommandLine command(CommandLine::NO_PROGRAM); 77 CommandLine command(CommandLine::NO_PROGRAM);
78 Status status = internal::ProcessExtensions(extensions, extension_dir.path(), 78 Status status = internal::ProcessExtensions(extensions, extension_dir.path(),
79 false, &command); 79 false, &command);
80 ASSERT_TRUE(status.IsOk()); 80 ASSERT_TRUE(status.IsOk());
81 ASSERT_TRUE(command.HasSwitch("load-extension")); 81 ASSERT_TRUE(command.HasSwitch("load-extension"));
82 CommandLine::StringType ext_paths = command.GetSwitchValueNative( 82 CommandLine::StringType ext_paths = command.GetSwitchValueNative(
83 "load-extension"); 83 "load-extension");
84 std::vector<CommandLine::StringType> ext_path_list; 84 std::vector<CommandLine::StringType> ext_path_list;
85 base::SplitString(ext_paths, FILE_PATH_LITERAL(','), &ext_path_list); 85 base::SplitString(ext_paths, FILE_PATH_LITERAL(','), &ext_path_list);
86 ASSERT_EQ(2u, ext_path_list.size()); 86 ASSERT_EQ(2u, ext_path_list.size());
87 ASSERT_TRUE(file_util::PathExists(base::FilePath(ext_path_list[0]))); 87 ASSERT_TRUE(base::PathExists(base::FilePath(ext_path_list[0])));
88 ASSERT_TRUE(file_util::PathExists(base::FilePath(ext_path_list[1]))); 88 ASSERT_TRUE(base::PathExists(base::FilePath(ext_path_list[1])));
89 } 89 }
90 90
91 namespace { 91 namespace {
92 92
93 void AssertEQ(const base::DictionaryValue& dict, const std::string& key, 93 void AssertEQ(const base::DictionaryValue& dict, const std::string& key,
94 const char* expected_value) { 94 const char* expected_value) {
95 std::string value; 95 std::string value;
96 ASSERT_TRUE(dict.GetString(key, &value)); 96 ASSERT_TRUE(dict.GetString(key, &value));
97 ASSERT_STREQ(value.c_str(), expected_value); 97 ASSERT_STREQ(value.c_str(), expected_value);
98 } 98 }
(...skipping 28 matching lines...) Expand all
127 base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State"); 127 base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State");
128 std::string local_state_str; 128 std::string local_state_str;
129 ASSERT_TRUE(file_util::ReadFileToString(local_state_file, &local_state_str)); 129 ASSERT_TRUE(file_util::ReadFileToString(local_state_file, &local_state_str));
130 scoped_ptr<base::Value> local_state_value( 130 scoped_ptr<base::Value> local_state_value(
131 base::JSONReader::Read(local_state_str)); 131 base::JSONReader::Read(local_state_str));
132 const base::DictionaryValue* local_state_dict = NULL; 132 const base::DictionaryValue* local_state_dict = NULL;
133 ASSERT_TRUE(local_state_value->GetAsDictionary(&local_state_dict)); 133 ASSERT_TRUE(local_state_value->GetAsDictionary(&local_state_dict));
134 AssertEQ(*local_state_dict, "myLocalKey", "ok"); 134 AssertEQ(*local_state_dict, "myLocalKey", "ok");
135 AssertEQ(*local_state_dict, "local.state.sub", "2"); 135 AssertEQ(*local_state_dict, "local.state.sub", "2");
136 } 136 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | chrome/test/chromedriver/session_commands_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698