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

Unified Diff: chrome/browser/importer/firefox_importer_utils_unittest.cc

Issue 10830098: Get the Firefox branding name dynamically (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/importer/firefox_importer_utils_unittest.cc
===================================================================
--- chrome/browser/importer/firefox_importer_utils_unittest.cc (revision 148898)
+++ chrome/browser/importer/firefox_importer_utils_unittest.cc (working copy)
@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/file_util.h"
+#include "base/scoped_temp_dir.h"
+#include "chrome/browser/importer/firefox_importer_utils.h"
+#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/l10n/l10n_util.h"
-#include "chrome/browser/importer/firefox_importer_utils.h"
-
struct GetPrefsJsValueCase {
std::string prefs_content;
std::string pref_name;
@@ -40,3 +43,63 @@
GetPrefsJsValueCases[i].pref_name));
}
}
+
+struct GetFirefoxImporterNameCase {
+ std::string app_ini_content;
+ int resource_id;
+} GetFirefoxImporterNameCases[] = {
+ // Basic case
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Name=Iceweasel\n"
+ "Version=10.0.6\n"
+ "BuildID=20120717115048\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ IDS_IMPORT_FROM_ICEWEASEL },
+ // Whitespace
+ { " \t[App] \n"
+ "Vendor=Mozilla\n"
+ " Name=Firefox\t \r\n"
+ "Version=10.0.6\n",
+ IDS_IMPORT_FROM_FIREFOX },
+ // No Name setting
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Version=10.0.6\n"
+ "BuildID=20120717115048\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ IDS_IMPORT_FROM_FIREFOX },
+ // No [App] section
+ { "[Foo]\n"
+ "Vendor=Mozilla\n"
+ "Name=Foo\n",
+ IDS_IMPORT_FROM_FIREFOX },
+ // Multiple Name settings in different sections
+ { "[Foo]\n"
+ "Vendor=Mozilla\n"
+ "Name=Firefox\n"
+ "[App]\n"
+ "Profile=mozilla/firefox\n"
+ "Name=iceweasel\n"
Ilya Sherman 2012/08/07 21:52:21 nit: Perhaps add a separate test case for case-ins
cristian.patrasciuc 2012/08/08 15:20:52 Done.
+ "[Bar]\n"
+ "Name=Bar\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ IDS_IMPORT_FROM_ICEWEASEL },
+ // Empty file
+ { "", IDS_IMPORT_FROM_FIREFOX }
+};
Ilya Sherman 2012/08/07 21:52:21 nit: Please move this definition either into the t
cristian.patrasciuc 2012/08/08 15:20:52 Done. I also moved the other definition inside the
+
+TEST(FirefoxImporterUtilsTest, GetFirefoxImporterName) {
+ ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ const FilePath app_ini_file(temp_dir.path().Append("application.ini"));
+ for (size_t i = 0; i < arraysize(GetFirefoxImporterNameCases); ++i) {
+ file_util::WriteFile(app_ini_file,
+ GetFirefoxImporterNameCases[i].app_ini_content.c_str(),
+ GetFirefoxImporterNameCases[i].app_ini_content.size());
+ EXPECT_EQ(GetFirefoxImporterName(temp_dir.path()),
+ l10n_util::GetStringUTF16(GetFirefoxImporterNameCases[i].resource_id));
+ }
+ EXPECT_EQ(GetFirefoxImporterName(FilePath("/invalid/path")),
+ l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX));
+}

Powered by Google App Engine
This is Rietveld 408576698