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

Side by Side Diff: sync/engine/syncer_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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
« no previous file with comments | « sync/api/sync_data.cc ('k') | sync/engine/syncer_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Syncer unit tests. Unfortunately a lot of these tests 5 // Syncer unit tests. Unfortunately a lot of these tests
6 // are outdated and need to be reworked and updated. 6 // are outdated and need to be reworked and updated.
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 ASSERT_FALSE(local_parent2_id_entry.good()); 1634 ASSERT_FALSE(local_parent2_id_entry.good());
1635 1635
1636 Entry entry_b(&rtrans, syncable::GET_BY_HANDLE, meta_handle_b); 1636 Entry entry_b(&rtrans, syncable::GET_BY_HANDLE, meta_handle_b);
1637 EXPECT_TRUE(entry_b.Get(syncable::ID).ServerKnows()); 1637 EXPECT_TRUE(entry_b.Get(syncable::ID).ServerKnows());
1638 EXPECT_TRUE(parent2.Get(syncable::ID) == entry_b.Get(syncable::PARENT_ID)); 1638 EXPECT_TRUE(parent2.Get(syncable::ID) == entry_b.Get(syncable::PARENT_ID));
1639 } 1639 }
1640 } 1640 }
1641 1641
1642 TEST_F(SyncerTest, UpdateWithZeroLengthName) { 1642 TEST_F(SyncerTest, UpdateWithZeroLengthName) {
1643 // One illegal update 1643 // One illegal update
1644 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10, 1644 mock_server_->AddUpdateDirectory(
1645 foreign_cache_guid(), "-1"); 1645 1, 0, std::string(), 1, 10, foreign_cache_guid(), "-1");
1646 // And one legal one that we're going to delete. 1646 // And one legal one that we're going to delete.
1647 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10, 1647 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10,
1648 foreign_cache_guid(), "-2"); 1648 foreign_cache_guid(), "-2");
1649 SyncShareNudge(); 1649 SyncShareNudge();
1650 // Delete the legal one. The new update has a null name. 1650 // Delete the legal one. The new update has a null name.
1651 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20, 1651 mock_server_->AddUpdateDirectory(
1652 foreign_cache_guid(), "-2"); 1652 2, 0, std::string(), 2, 20, foreign_cache_guid(), "-2");
1653 mock_server_->SetLastUpdateDeleted(); 1653 mock_server_->SetLastUpdateDeleted();
1654 SyncShareNudge(); 1654 SyncShareNudge();
1655 } 1655 }
1656 1656
1657 TEST_F(SyncerTest, TestBasicUpdate) { 1657 TEST_F(SyncerTest, TestBasicUpdate) {
1658 string id = "some_id"; 1658 string id = "some_id";
1659 string parent_id = "0"; 1659 string parent_id = "0";
1660 string name = "in_root"; 1660 string name = "in_root";
1661 int64 version = 10; 1661 int64 version = 10;
1662 int64 timestamp = 10; 1662 int64 timestamp = 10;
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == "bob"); 4037 ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == "bob");
4038 4038
4039 // Try to lookup by the tagname. These should fail. 4039 // Try to lookup by the tagname. These should fail.
4040 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); 4040 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha");
4041 EXPECT_FALSE(tag_alpha.good()); 4041 EXPECT_FALSE(tag_alpha.good());
4042 Entry tag_bob(&trans, GET_BY_SERVER_TAG, "bob"); 4042 Entry tag_bob(&trans, GET_BY_SERVER_TAG, "bob");
4043 EXPECT_FALSE(tag_bob.good()); 4043 EXPECT_FALSE(tag_bob.good());
4044 } 4044 }
4045 4045
4046 // Now download some tagged items as updates. 4046 // Now download some tagged items as updates.
4047 mock_server_->AddUpdateDirectory(1, 0, "update1", 1, 10, "", ""); 4047 mock_server_->AddUpdateDirectory(
4048 1, 0, "update1", 1, 10, std::string(), std::string());
4048 mock_server_->SetLastUpdateServerTag("alpha"); 4049 mock_server_->SetLastUpdateServerTag("alpha");
4049 mock_server_->AddUpdateDirectory(2, 0, "update2", 2, 20, "", ""); 4050 mock_server_->AddUpdateDirectory(
4051 2, 0, "update2", 2, 20, std::string(), std::string());
4050 mock_server_->SetLastUpdateServerTag("bob"); 4052 mock_server_->SetLastUpdateServerTag("bob");
4051 SyncShareNudge(); 4053 SyncShareNudge();
4052 4054
4053 { 4055 {
4054 syncable::ReadTransaction trans(FROM_HERE, directory()); 4056 syncable::ReadTransaction trans(FROM_HERE, directory());
4055 4057
4056 // The new items should be applied as new entries, and we should be able 4058 // The new items should be applied as new entries, and we should be able
4057 // to look them up by their tag values. 4059 // to look them up by their tag values.
4058 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); 4060 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha");
4059 ASSERT_TRUE(tag_alpha.good()); 4061 ASSERT_TRUE(tag_alpha.good());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
4245 EXPECT_FALSE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans)); 4247 EXPECT_FALSE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans));
4246 } 4248 }
4247 } 4249 }
4248 4250
4249 TEST_F(SyncerTest, GetKeyEmpty) { 4251 TEST_F(SyncerTest, GetKeyEmpty) {
4250 { 4252 {
4251 syncable::ReadTransaction rtrans(FROM_HERE, directory()); 4253 syncable::ReadTransaction rtrans(FROM_HERE, directory());
4252 EXPECT_TRUE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans)); 4254 EXPECT_TRUE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans));
4253 } 4255 }
4254 4256
4255 mock_server_->SetKeystoreKey(""); 4257 mock_server_->SetKeystoreKey(std::string());
4256 SyncShareConfigure(); 4258 SyncShareConfigure();
4257 4259
4258 EXPECT_NE(session_->status_controller().last_get_key_result(), SYNCER_OK); 4260 EXPECT_NE(session_->status_controller().last_get_key_result(), SYNCER_OK);
4259 { 4261 {
4260 syncable::ReadTransaction rtrans(FROM_HERE, directory()); 4262 syncable::ReadTransaction rtrans(FROM_HERE, directory());
4261 EXPECT_TRUE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans)); 4263 EXPECT_TRUE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans));
4262 } 4264 }
4263 } 4265 }
4264 4266
4265 // Test what happens if a client deletes, then recreates, an object very 4267 // Test what happens if a client deletes, then recreates, an object very
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
4799 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 4801 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
4800 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 4802 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
4801 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 4803 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
4802 } else { 4804 } else {
4803 EXPECT_TRUE(final_monitor_records.empty()) 4805 EXPECT_TRUE(final_monitor_records.empty())
4804 << "Should not restore records after successful bookmark commit."; 4806 << "Should not restore records after successful bookmark commit.";
4805 } 4807 }
4806 } 4808 }
4807 4809
4808 } // namespace syncer 4810 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/sync_data.cc ('k') | sync/engine/syncer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698