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, SingleExtensionWithBgPage) { | 48 TEST(ProcessExtensions, SingleExtensionWithBgPage) { |
50 std::vector<std::string> extensions; | 49 std::vector<std::string> extensions; |
51 ASSERT_TRUE(AddExtensionForInstall("ext_slow_loader.crx", &extensions)); | 50 ASSERT_TRUE(AddExtensionForInstall("ext_slow_loader.crx", &extensions)); |
52 | 51 |
53 base::ScopedTempDir extension_dir; | 52 base::ScopedTempDir extension_dir; |
54 ASSERT_TRUE(extension_dir.CreateUniqueTempDir()); | 53 ASSERT_TRUE(extension_dir.CreateUniqueTempDir()); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State"); | 162 base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State"); |
164 std::string local_state_str; | 163 std::string local_state_str; |
165 ASSERT_TRUE(base::ReadFileToString(local_state_file, &local_state_str)); | 164 ASSERT_TRUE(base::ReadFileToString(local_state_file, &local_state_str)); |
166 scoped_ptr<base::Value> local_state_value( | 165 scoped_ptr<base::Value> local_state_value( |
167 base::JSONReader::Read(local_state_str)); | 166 base::JSONReader::Read(local_state_str)); |
168 const base::DictionaryValue* local_state_dict = NULL; | 167 const base::DictionaryValue* local_state_dict = NULL; |
169 ASSERT_TRUE(local_state_value->GetAsDictionary(&local_state_dict)); | 168 ASSERT_TRUE(local_state_value->GetAsDictionary(&local_state_dict)); |
170 AssertEQ(*local_state_dict, "myLocalKey", "ok"); | 169 AssertEQ(*local_state_dict, "myLocalKey", "ok"); |
171 AssertEQ(*local_state_dict, "local.state.sub", "2"); | 170 AssertEQ(*local_state_dict, "local.state.sub", "2"); |
172 } | 171 } |
OLD | NEW |