OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/common/importer/firefox_importer_utils.h" | 5 #include "chrome/common/importer/firefox_importer_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 GetPrefsJsValueCases[i].pref_value, | 101 GetPrefsJsValueCases[i].pref_value, |
102 GetPrefsJsValue(GetPrefsJsValueCases[i].prefs_content, | 102 GetPrefsJsValue(GetPrefsJsValueCases[i].prefs_content, |
103 GetPrefsJsValueCases[i].pref_name)); | 103 GetPrefsJsValueCases[i].pref_name)); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 TEST(FirefoxImporterUtilsTest, GetFirefoxImporterName) { | 107 TEST(FirefoxImporterUtilsTest, GetFirefoxImporterName) { |
108 base::ScopedTempDir temp_dir; | 108 base::ScopedTempDir temp_dir; |
109 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 109 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
110 const base::FilePath app_ini_file( | 110 const base::FilePath app_ini_file( |
111 temp_dir.path().AppendASCII("application.ini")); | 111 temp_dir.GetPath().AppendASCII("application.ini")); |
112 for (size_t i = 0; i < arraysize(GetFirefoxImporterNameCases); ++i) { | 112 for (size_t i = 0; i < arraysize(GetFirefoxImporterNameCases); ++i) { |
113 base::WriteFile(app_ini_file, | 113 base::WriteFile(app_ini_file, |
114 GetFirefoxImporterNameCases[i].app_ini_content.c_str(), | 114 GetFirefoxImporterNameCases[i].app_ini_content.c_str(), |
115 GetFirefoxImporterNameCases[i].app_ini_content.size()); | 115 GetFirefoxImporterNameCases[i].app_ini_content.size()); |
116 EXPECT_EQ(GetFirefoxImporterName(temp_dir.path()), | 116 EXPECT_EQ( |
| 117 GetFirefoxImporterName(temp_dir.GetPath()), |
117 l10n_util::GetStringUTF16(GetFirefoxImporterNameCases[i].resource_id)); | 118 l10n_util::GetStringUTF16(GetFirefoxImporterNameCases[i].resource_id)); |
118 } | 119 } |
119 EXPECT_EQ(l10n_util::GetStringUTF16( | 120 EXPECT_EQ(l10n_util::GetStringUTF16( |
120 IDS_IMPORT_FROM_FIREFOX), | 121 IDS_IMPORT_FROM_FIREFOX), |
121 GetFirefoxImporterName(base::FilePath( | 122 GetFirefoxImporterName(base::FilePath( |
122 FILE_PATH_LITERAL("/invalid/path")))); | 123 FILE_PATH_LITERAL("/invalid/path")))); |
123 } | 124 } |
124 | 125 |
125 TEST(FirefoxImporterUtilsTest, GetFirefoxProfilePath) { | 126 TEST(FirefoxImporterUtilsTest, GetFirefoxProfilePath) { |
126 base::DictionaryValue no_profiles; | 127 base::DictionaryValue no_profiles; |
(...skipping 26 matching lines...) Expand all Loading... |
153 | 154 |
154 base::DictionaryValue default_second; | 155 base::DictionaryValue default_second; |
155 default_second.SetString("Profile0.Path", "first"); | 156 default_second.SetString("Profile0.Path", "first"); |
156 default_second.SetString("Profile0.IsRelative", "0"); | 157 default_second.SetString("Profile0.IsRelative", "0"); |
157 default_second.SetString("Profile1.Path", "second"); | 158 default_second.SetString("Profile1.Path", "second"); |
158 default_second.SetString("Profile1.IsRelative", "0"); | 159 default_second.SetString("Profile1.IsRelative", "0"); |
159 default_second.SetString("Profile1.Default", "1"); | 160 default_second.SetString("Profile1.Default", "1"); |
160 EXPECT_EQ("second", | 161 EXPECT_EQ("second", |
161 GetFirefoxProfilePathFromDictionary(default_second).MaybeAsASCII()); | 162 GetFirefoxProfilePathFromDictionary(default_second).MaybeAsASCII()); |
162 } | 163 } |
OLD | NEW |