OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 std::vector<std::string>* extensions) { | 33 std::vector<std::string>* extensions) { |
34 base::FilePath source_root; | 34 base::FilePath source_root; |
35 PathService::Get(base::DIR_SOURCE_ROOT, &source_root); | 35 PathService::Get(base::DIR_SOURCE_ROOT, &source_root); |
36 base::FilePath crx_file_path = source_root.AppendASCII( | 36 base::FilePath crx_file_path = source_root.AppendASCII( |
37 "chrome/test/data/chromedriver/" + relative_path); | 37 "chrome/test/data/chromedriver/" + relative_path); |
38 std::string crx_contents; | 38 std::string crx_contents; |
39 if (!base::ReadFileToString(crx_file_path, &crx_contents)) | 39 if (!base::ReadFileToString(crx_file_path, &crx_contents)) |
40 return false; | 40 return false; |
41 | 41 |
42 std::string crx_encoded; | 42 std::string crx_encoded; |
43 if (!base::Base64Encode(crx_contents, &crx_encoded)) | 43 base::Base64Encode(crx_contents, &crx_encoded); |
44 return false; | |
45 extensions->push_back(crx_encoded); | 44 extensions->push_back(crx_encoded); |
46 return true; | 45 return true; |
47 } | 46 } |
48 | 47 |
49 TEST(ProcessExtensions, GenerateIds) { | 48 TEST(ProcessExtensions, GenerateIds) { |
50 std::vector<std::string> extensions; | 49 std::vector<std::string> extensions; |
51 base::ScopedTempDir extension_dir; | 50 base::ScopedTempDir extension_dir; |
52 Switches switches; | 51 Switches switches; |
53 std::vector<std::string> bg_pages; | 52 std::vector<std::string> bg_pages; |
54 | 53 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State"); | 187 base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State"); |
189 std::string local_state_str; | 188 std::string local_state_str; |
190 ASSERT_TRUE(base::ReadFileToString(local_state_file, &local_state_str)); | 189 ASSERT_TRUE(base::ReadFileToString(local_state_file, &local_state_str)); |
191 scoped_ptr<base::Value> local_state_value( | 190 scoped_ptr<base::Value> local_state_value( |
192 base::JSONReader::Read(local_state_str)); | 191 base::JSONReader::Read(local_state_str)); |
193 const base::DictionaryValue* local_state_dict = NULL; | 192 const base::DictionaryValue* local_state_dict = NULL; |
194 ASSERT_TRUE(local_state_value->GetAsDictionary(&local_state_dict)); | 193 ASSERT_TRUE(local_state_value->GetAsDictionary(&local_state_dict)); |
195 AssertEQ(*local_state_dict, "myLocalKey", "ok"); | 194 AssertEQ(*local_state_dict, "myLocalKey", "ok"); |
196 AssertEQ(*local_state_dict, "local.state.sub", "2"); | 195 AssertEQ(*local_state_dict, "local.state.sub", "2"); |
197 } | 196 } |
OLD | NEW |