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

Side by Side Diff: ui/base/resource/data_pack_unittest.cc

Issue 7744017: Updated *.pak file format to support both UTF8 and UTF16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up comments/ Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 std::string three("three"); 47 std::string three("three");
48 std::string four("four"); 48 std::string four("four");
49 std::string fifteen("fifteen"); 49 std::string fifteen("fifteen");
50 50
51 std::map<uint16, base::StringPiece> resources; 51 std::map<uint16, base::StringPiece> resources;
52 resources.insert(std::make_pair(1, base::StringPiece(one))); 52 resources.insert(std::make_pair(1, base::StringPiece(one)));
53 resources.insert(std::make_pair(2, base::StringPiece(two))); 53 resources.insert(std::make_pair(2, base::StringPiece(two)));
54 resources.insert(std::make_pair(15, base::StringPiece(fifteen))); 54 resources.insert(std::make_pair(15, base::StringPiece(fifteen)));
55 resources.insert(std::make_pair(3, base::StringPiece(three))); 55 resources.insert(std::make_pair(3, base::StringPiece(three)));
56 resources.insert(std::make_pair(4, base::StringPiece(four))); 56 resources.insert(std::make_pair(4, base::StringPiece(four)));
57 ASSERT_TRUE(DataPack::WritePack(file, resources)); 57 ASSERT_TRUE(DataPack::WritePack(file, resources, DataPack::UTF16));
tony 2011/08/29 21:24:39 Can you have the test write/read the data as UTF16
marcvs 2011/08/30 07:58:55 I created parameterized tests with TEST_P and INST
58 58
59 // Now try to read the data back in. 59 // Now try to read the data back in.
60 DataPack pack; 60 DataPack pack;
61 ASSERT_TRUE(pack.Load(file)); 61 ASSERT_TRUE(pack.Load(file));
62 EXPECT_EQ(pack.GetTextEncodingType(), DataPack::UTF16);
62 63
63 base::StringPiece data; 64 base::StringPiece data;
64 ASSERT_TRUE(pack.GetStringPiece(1, &data)); 65 ASSERT_TRUE(pack.GetStringPiece(1, &data));
65 EXPECT_EQ(one, data); 66 EXPECT_EQ(one, data);
66 ASSERT_TRUE(pack.GetStringPiece(2, &data)); 67 ASSERT_TRUE(pack.GetStringPiece(2, &data));
67 EXPECT_EQ(two, data); 68 EXPECT_EQ(two, data);
68 ASSERT_TRUE(pack.GetStringPiece(3, &data)); 69 ASSERT_TRUE(pack.GetStringPiece(3, &data));
69 EXPECT_EQ(three, data); 70 EXPECT_EQ(three, data);
70 ASSERT_TRUE(pack.GetStringPiece(4, &data)); 71 ASSERT_TRUE(pack.GetStringPiece(4, &data));
71 EXPECT_EQ(four, data); 72 EXPECT_EQ(four, data);
72 ASSERT_TRUE(pack.GetStringPiece(15, &data)); 73 ASSERT_TRUE(pack.GetStringPiece(15, &data));
73 EXPECT_EQ(fifteen, data); 74 EXPECT_EQ(fifteen, data);
74 } 75 }
75 76
76 } // namespace ui 77 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698