From 4576e9f095e767e8b78861e2cdde6d6730ad5267 Mon Sep 17 00:00:00 2001 From: "cpu@chromium.org" Date: Mon, 8 Mar 2010 18:42:25 +0000 Subject: 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 --- .../installer/util/master_preferences_unittest.cc | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'chrome/installer/util/master_preferences_unittest.cc') 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 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)); +} -- cgit v1.1