summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/master_preferences_unittest.cc
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 18:42:25 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 18:42:25 +0000
commit4576e9f095e767e8b78861e2cdde6d6730ad5267 (patch)
tree69df195ef0855087872358b99ca9025cbf442eb1 /chrome/installer/util/master_preferences_unittest.cc
parent0afa1c4259d103037bbce99a5b52057aaaef4f34 (diff)
downloadchromium_src-4576e9f095e767e8b78861e2cdde6d6730ad5267.zip
chromium_src-4576e9f095e767e8b78861e2cdde6d6730ad5267.tar.gz
chromium_src-4576e9f095e767e8b78861e2cdde6d6730ad5267.tar.bz2
Add support for auto-installing extensions at first run via master prefs
This a even lower impact method, with no new fields added. This is how it works: 1- The extension pared down manifest goes into the master prefs 2- The master prefs become the prefs at first run 3- First run notices an extensions block, an triggers an extensions check 4- The full extension gets updated then BUG=37573 TEST=ut included, also see bug Review URL: http://codereview.chromium.org/669218 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/master_preferences_unittest.cc')
-rw-r--r--chrome/installer/util/master_preferences_unittest.cc39
1 files changed, 38 insertions, 1 deletions
diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc
index 18e560f..8ff41e0 100644
--- a/chrome/installer/util/master_preferences_unittest.cc
+++ b/chrome/installer/util/master_preferences_unittest.cc
@@ -4,8 +4,10 @@
//
// Unit tests for master preferences related methods.
-#include "base/scoped_ptr.h"
#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/scoped_ptr.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/json_value_serializer.h"
#include "chrome/installer/util/master_preferences.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -229,3 +231,38 @@ TEST_F(MasterPreferencesTest, FirstRunBookMarks) {
EXPECT_EQ(L"http://google.com/b1", bookmarks[0]);
EXPECT_EQ(L"https://google.com/b2", bookmarks[1]);
}
+
+// In this test instead of using our synthetic json file, we use an
+// actual test case from the extensions unittest. The hope here is that if
+// they change something in the manifest this test will break, but in
+// general it is expected the extension format to be backwards compatible.
+TEST(MasterPrefsExtension, ValidateExtensionJSON) {
+ FilePath prefs_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &prefs_path));
+ prefs_path = prefs_path.AppendASCII("extensions")
+ .AppendASCII("good").AppendASCII("Preferences");
+
+ scoped_ptr<DictionaryValue> prefs(
+ installer_util::ParseDistributionPreferences(prefs_path));
+ ASSERT_TRUE(prefs.get() != NULL);
+ DictionaryValue* extensions = NULL;
+ EXPECT_TRUE(installer_util::HasExtensionsBlock(prefs.get(), &extensions));
+ int location = 0;
+ EXPECT_TRUE(extensions->GetInteger(
+ L"behllobkkfkfnphdnhnkndlbkcpglgmj.location", &location));
+ int state = 0;
+ EXPECT_TRUE(extensions->GetInteger(
+ L"behllobkkfkfnphdnhnkndlbkcpglgmj.state", &state));
+ std::wstring path;
+ EXPECT_TRUE(extensions->GetString(
+ L"behllobkkfkfnphdnhnkndlbkcpglgmj.path", &path));
+ std::wstring key;
+ EXPECT_TRUE(extensions->GetString(
+ L"behllobkkfkfnphdnhnkndlbkcpglgmj.manifest.key", &key));
+ std::wstring name;
+ EXPECT_TRUE(extensions->GetString(
+ L"behllobkkfkfnphdnhnkndlbkcpglgmj.manifest.name", &name));
+ std::wstring version;
+ EXPECT_TRUE(extensions->GetString(
+ L"behllobkkfkfnphdnhnkndlbkcpglgmj.manifest.version", &version));
+}