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

Side by Side Diff: chrome/browser/sync/syncable/syncable_unittest.cc

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nigori access in testserver Created 8 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/sync/syncable/syncable.h" 5 #include "chrome/browser/sync/syncable/syncable.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ADD_FAILURE(); 55 ADD_FAILURE();
56 } 56 }
57 } 57 }
58 58
59 namespace { 59 namespace {
60 void PutDataAsBookmarkFavicon(WriteTransaction* wtrans, 60 void PutDataAsBookmarkFavicon(WriteTransaction* wtrans,
61 MutableEntry* e, 61 MutableEntry* e,
62 const char* bytes, 62 const char* bytes,
63 size_t bytes_length) { 63 size_t bytes_length) {
64 sync_pb::EntitySpecifics specifics; 64 sync_pb::EntitySpecifics specifics;
65 specifics.MutableExtension(sync_pb::bookmark)->set_url("http://demo/"); 65 specifics.mutable_bookmark()->set_url("http://demo/");
66 specifics.MutableExtension(sync_pb::bookmark)->set_favicon(bytes, 66 specifics.mutable_bookmark()->set_favicon(bytes, bytes_length);
67 bytes_length);
68 e->Put(SPECIFICS, specifics); 67 e->Put(SPECIFICS, specifics);
69 } 68 }
70 69
71 void ExpectDataFromBookmarkFaviconEquals(BaseTransaction* trans, 70 void ExpectDataFromBookmarkFaviconEquals(BaseTransaction* trans,
72 Entry* e, 71 Entry* e,
73 const char* bytes, 72 const char* bytes,
74 size_t bytes_length) { 73 size_t bytes_length) {
75 ASSERT_TRUE(e->good()); 74 ASSERT_TRUE(e->good());
76 ASSERT_TRUE(e->Get(SPECIFICS).HasExtension(sync_pb::bookmark)); 75 ASSERT_TRUE(e->Get(SPECIFICS).has_bookmark());
77 ASSERT_EQ("http://demo/", 76 ASSERT_EQ("http://demo/", e->Get(SPECIFICS).bookmark().url());
78 e->Get(SPECIFICS).GetExtension(sync_pb::bookmark).url());
79 ASSERT_EQ(std::string(bytes, bytes_length), 77 ASSERT_EQ(std::string(bytes, bytes_length),
80 e->Get(SPECIFICS).GetExtension(sync_pb::bookmark).favicon()); 78 e->Get(SPECIFICS).bookmark().favicon());
81 } 79 }
82 } // namespace 80 } // namespace
83 81
84 class SyncableGeneralTest : public testing::Test { 82 class SyncableGeneralTest : public testing::Test {
85 public: 83 public:
86 virtual void SetUp() { 84 virtual void SetUp() {
87 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 85 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
88 db_path_ = temp_dir_.path().Append( 86 db_path_ = temp_dir_.path().Append(
89 FILE_PATH_LITERAL("SyncableTest.sqlite3")); 87 FILE_PATH_LITERAL("SyncableTest.sqlite3"));
90 } 88 }
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 EntryKernel create_post_save, update_post_save; 1192 EntryKernel create_post_save, update_post_save;
1195 std::string create_name = "Create"; 1193 std::string create_name = "Create";
1196 1194
1197 { 1195 {
1198 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); 1196 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
1199 MutableEntry create(&trans, CREATE, trans.root_id(), create_name); 1197 MutableEntry create(&trans, CREATE, trans.root_id(), create_name);
1200 MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, update_id); 1198 MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, update_id);
1201 create.Put(IS_UNSYNCED, true); 1199 create.Put(IS_UNSYNCED, true);
1202 update.Put(IS_UNAPPLIED_UPDATE, true); 1200 update.Put(IS_UNAPPLIED_UPDATE, true);
1203 sync_pb::EntitySpecifics specifics; 1201 sync_pb::EntitySpecifics specifics;
1204 specifics.MutableExtension(sync_pb::bookmark)->set_favicon("PNG"); 1202 specifics.mutable_bookmark()->set_favicon("PNG");
1205 specifics.MutableExtension(sync_pb::bookmark)->set_url("http://nowhere"); 1203 specifics.mutable_bookmark()->set_url("http://nowhere");
1206 create.Put(SPECIFICS, specifics); 1204 create.Put(SPECIFICS, specifics);
1207 create_pre_save = create.GetKernelCopy(); 1205 create_pre_save = create.GetKernelCopy();
1208 update_pre_save = update.GetKernelCopy(); 1206 update_pre_save = update.GetKernelCopy();
1209 create_id = create.Get(ID); 1207 create_id = create.Get(ID);
1210 } 1208 }
1211 1209
1212 dir_->SaveChanges(); 1210 dir_->SaveChanges();
1213 browser_sync::TestUnrecoverableErrorHandler handler; 1211 browser_sync::TestUnrecoverableErrorHandler handler;
1214 dir_.reset(new Directory(&handler, NULL)); 1212 dir_.reset(new Directory(&handler, NULL));
1215 ASSERT_TRUE(dir_.get()); 1213 ASSERT_TRUE(dir_.get());
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { 1860 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) {
1863 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); 1861 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true));
1864 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); 1862 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true));
1865 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); 1863 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false));
1866 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); 1864 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false));
1867 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); 1865 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true));
1868 } 1866 }
1869 1867
1870 } // namespace 1868 } // namespace
1871 } // namespace syncable 1869 } // namespace syncable
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698