diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-11 20:55:30 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-11 20:55:30 +0000 |
commit | 5973945e4c3d2baf2b92d11be55c1692a09b12e3 (patch) | |
tree | e2abfada45cf20c85186c10e27c966c2cbc6bf55 /base/data_pack_unittest.cc | |
parent | 45c019ca34f3c9576ad1c3d24a885f97f1b80ba2 (diff) | |
download | chromium_src-5973945e4c3d2baf2b92d11be55c1692a09b12e3.zip chromium_src-5973945e4c3d2baf2b92d11be55c1692a09b12e3.tar.gz chromium_src-5973945e4c3d2baf2b92d11be55c1692a09b12e3.tar.bz2 |
Completely redo how themes are stored on disk and processed at install time.
Rewrites most of BrowserThemeProvider and adds a new class
BrowserThemePack. BrowserThemePack takes all the logic of generating resources
out of the BrowserThemeProvider, does all of them at theme install time
(previously, we lazily generated all the button images and a good number of
colors, which muddled logic quite a bit), and then writes all the data out into
an mmap()able file to speed startup when a theme is installed.
In addition, this changes how the GtkThemeProvider works. The GtkThemeProvider
now generates all of its images lazily and doesn't reach into the
implementation details of BrowserThemeProvider as it used to.
BUG=24493,21121
TEST=All the new unit tests pass. All the complex theme startup tests go faster.
Review URL: http://codereview.chromium.org/460050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/data_pack_unittest.cc')
-rw-r--r-- | base/data_pack_unittest.cc | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/base/data_pack_unittest.cc b/base/data_pack_unittest.cc index a62acf0..d089b28 100644 --- a/base/data_pack_unittest.cc +++ b/base/data_pack_unittest.cc @@ -5,24 +5,20 @@ #include "base/data_pack.h" #include "base/file_path.h" +#include "base/file_util.h" #include "base/path_service.h" +#include "base/scoped_temp_dir.h" #include "base/string_piece.h" #include "testing/gtest/include/gtest/gtest.h" -class DataPackTest : public testing::Test { - public: - DataPackTest() { - PathService::Get(base::DIR_SOURCE_ROOT, &data_path_); - data_path_ = data_path_.Append( +TEST(DataPackTest, Load) { + FilePath data_path; + PathService::Get(base::DIR_SOURCE_ROOT, &data_path); + data_path = data_path.Append( FILE_PATH_LITERAL("base/data/data_pack_unittest/sample.pak")); - } - FilePath data_path_; -}; - -TEST_F(DataPackTest, Load) { base::DataPack pack; - ASSERT_TRUE(pack.Load(data_path_)); + ASSERT_TRUE(pack.Load(data_path)); base::StringPiece data; ASSERT_TRUE(pack.GetStringPiece(4, &data)); @@ -39,3 +35,39 @@ TEST_F(DataPackTest, Load) { // Try looking up an invalid key. ASSERT_FALSE(pack.GetStringPiece(140, &data)); } + +TEST(DataPackTest, Write) { + ScopedTempDir dir; + ASSERT_TRUE(dir.CreateUniqueTempDir()); + FilePath file = dir.path().Append(FILE_PATH_LITERAL("data.pak")); + + std::string one("one"); + std::string two("two"); + std::string three("three"); + std::string four("four"); + std::string fifteen("fifteen"); + + std::map<uint32, base::StringPiece> resources; + resources.insert(std::make_pair(1, base::StringPiece(one))); + resources.insert(std::make_pair(2, base::StringPiece(two))); + resources.insert(std::make_pair(15, base::StringPiece(fifteen))); + resources.insert(std::make_pair(3, base::StringPiece(three))); + resources.insert(std::make_pair(4, base::StringPiece(four))); + ASSERT_TRUE(base::DataPack::WritePack(file, resources)); + + // Now try to read the data back in. + base::DataPack pack; + ASSERT_TRUE(pack.Load(file)); + + base::StringPiece data; + ASSERT_TRUE(pack.GetStringPiece(1, &data)); + EXPECT_EQ(one, data); + ASSERT_TRUE(pack.GetStringPiece(2, &data)); + EXPECT_EQ(two, data); + ASSERT_TRUE(pack.GetStringPiece(3, &data)); + EXPECT_EQ(three, data); + ASSERT_TRUE(pack.GetStringPiece(4, &data)); + EXPECT_EQ(four, data); + ASSERT_TRUE(pack.GetStringPiece(15, &data)); + EXPECT_EQ(fifteen, data); +} |