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

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, 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 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,11 @@
// 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 "testing/gtest/include/gtest/gtest.h"
-#include "chrome/browser/importer/firefox_importer_utils.h"
-
struct GetPrefsJsValueCase {
std::string prefs_content;
std::string pref_name;
@@ -40,3 +41,62 @@
GetPrefsJsValueCases[i].pref_name));
}
}
+
+struct GetFirefoxBrandingNameCase {
+ std::string app_ini_content;
+ std::string branding_name;
+} GetFirefoxBrandingNameCases[] = {
+ // Basic case
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Name=CUSTOM_NAME\n"
+ "Version=10.0.6\n"
+ "BuildID=20120717115048\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ "CUSTOM_NAME" },
+ // Whitespace
+ { " \t[App] \n"
+ "Vendor=Mozilla\n"
+ " Name=CUSTOM_NAME\t \r\n"
+ "Version=10.0.6\n",
+ "CUSTOM_NAME" },
+ // No Name setting
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Version=10.0.6\n"
+ "BuildID=20120717115048\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ "" },
+ // No [App] section
+ { "[Foo]\n"
+ "Vendor=Mozilla\n"
+ "Name=Foo\n",
+ "" },
+ // Multiple Name settings in different sections
+ { "[Foo]\n"
+ "Vendor=Mozilla\n"
+ "Name=Foo\n"
+ "[App]\n"
+ "Profile=mozilla/firefox\n"
+ "Name=CUSTOM_NAME\n"
+ "[Bar]\n"
+ "Name=Bar\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ "CUSTOM_NAME" },
+ // Empty file
+ { "", "" }
+};
+
+TEST(FirefoxImporterUtilsTest, GetFirefoxBrandingName) {
+ 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(GetFirefoxBrandingNameCases); ++i) {
+ file_util::WriteFile(app_ini_file,
+ GetFirefoxBrandingNameCases[i].app_ini_content.c_str(),
+ GetFirefoxBrandingNameCases[i].app_ini_content.size());
+ EXPECT_EQ(GetFirefoxBrandingNameCases[i].branding_name,
+ GetFirefoxBrandingName(temp_dir.path()));
+ }
+ EXPECT_EQ("", GetFirefoxBrandingName(FilePath("/invalid/path")));
+}

Powered by Google App Engine
This is Rietveld 408576698