summaryrefslogtreecommitdiffstats
path: root/base/data_pack_unittest.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-14 20:48:07 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-14 20:48:07 +0000
commitf017cc9f926a81638e324b51bd418ac7f7feeee0 (patch)
tree8db77306164b5d4498eac4ae729753095430a2e5 /base/data_pack_unittest.cc
parent3396dc0d719aeca9d4593dfe0f1ab62cdac1629f (diff)
downloadchromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.zip
chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.tar.gz
chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.tar.bz2
Try 2: Completely redo how themes are stored on disk and processed at install time.
Same as previous patch, except we now have a BrowserThemeProvider::GetDefaultDisplayProperty() so we don't have UMRs in ntp_resource_cache.cc. BUG=24493,21121 TEST=All the new unit tests pass. All the complex theme startup tests go faster. Previous Review URL: http://codereview.chromium.org/460050 Review URL: http://codereview.chromium.org/499004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/data_pack_unittest.cc')
-rw-r--r--base/data_pack_unittest.cc54
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);
+}