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

Side by Side Diff: components/sync/engine_impl/syncer_unittest.cc

Issue 2455343003: [Sync] Replaced ASSERT/EXPECT_TRUE/FALSE with expected/actual checks. (Closed)
Patch Set: \Updates for Max and rebase. Created 4 years, 1 month 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
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 #include "components/sync/engine_impl/syncer.h" 5 #include "components/sync/engine_impl/syncer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 entry.PutServerParentId(trans.root_id()); 448 entry.PutServerParentId(trans.root_id());
449 break; 449 break;
450 default: 450 default:
451 FAIL() << "Bad value in CommitOrderingTest list"; 451 FAIL() << "Bad value in CommitOrderingTest list";
452 } 452 }
453 } 453 }
454 test++; 454 test++;
455 } 455 }
456 } 456 }
457 EXPECT_TRUE(SyncShareNudge()); 457 EXPECT_TRUE(SyncShareNudge());
458 ASSERT_TRUE(expected_positions.size() == 458 ASSERT_EQ(expected_positions.size(), mock_server_->committed_ids().size());
459 mock_server_->committed_ids().size());
460 // If this test starts failing, be aware other sort orders could be valid. 459 // If this test starts failing, be aware other sort orders could be valid.
461 for (size_t i = 0; i < expected_positions.size(); ++i) { 460 for (size_t i = 0; i < expected_positions.size(); ++i) {
462 SCOPED_TRACE(i); 461 SCOPED_TRACE(i);
463 EXPECT_EQ(1u, expected_positions.count(i)); 462 EXPECT_EQ(1u, expected_positions.count(i));
464 EXPECT_EQ(expected_positions[i], mock_server_->committed_ids()[i]); 463 EXPECT_EQ(expected_positions[i], mock_server_->committed_ids()[i]);
465 } 464 }
466 } 465 }
467 466
468 CommitCounters GetCommitCounters(ModelType type) { 467 CommitCounters GetCommitCounters(ModelType type) {
469 return debug_info_cache_.GetLatestCommitCounters(type); 468 return debug_info_cache_.GetLatestCommitCounters(type);
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 GetOnlyEntryWithName(&rtrans, parent.GetId(), parent2_name)); 1943 GetOnlyEntryWithName(&rtrans, parent.GetId(), parent2_name));
1945 ASSERT_TRUE(parent2.good()); 1944 ASSERT_TRUE(parent2.good());
1946 EXPECT_TRUE(parent2.GetId().ServerKnows()); 1945 EXPECT_TRUE(parent2.GetId().ServerKnows());
1947 1946
1948 // Id changed on commit, so this should fail. 1947 // Id changed on commit, so this should fail.
1949 Entry local_parent2_id_entry(&rtrans, GET_BY_ID, parent2_local_id); 1948 Entry local_parent2_id_entry(&rtrans, GET_BY_ID, parent2_local_id);
1950 ASSERT_FALSE(local_parent2_id_entry.good()); 1949 ASSERT_FALSE(local_parent2_id_entry.good());
1951 1950
1952 Entry entry_b(&rtrans, GET_BY_HANDLE, meta_handle_b); 1951 Entry entry_b(&rtrans, GET_BY_HANDLE, meta_handle_b);
1953 EXPECT_TRUE(entry_b.GetId().ServerKnows()); 1952 EXPECT_TRUE(entry_b.GetId().ServerKnows());
1954 EXPECT_TRUE(parent2.GetId() == entry_b.GetParentId()); 1953 EXPECT_EQ(parent2.GetId(), entry_b.GetParentId());
1955 } 1954 }
1956 } 1955 }
1957 1956
1958 TEST_F(SyncerTest, UpdateWithZeroLengthName) { 1957 TEST_F(SyncerTest, UpdateWithZeroLengthName) {
1959 // One illegal update 1958 // One illegal update
1960 mock_server_->AddUpdateDirectory(1, 0, std::string(), 1, 10, 1959 mock_server_->AddUpdateDirectory(1, 0, std::string(), 1, 10,
1961 foreign_cache_guid(), "-1"); 1960 foreign_cache_guid(), "-1");
1962 // And one legal one that we're going to delete. 1961 // And one legal one that we're going to delete.
1963 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10, foreign_cache_guid(), 1962 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10, foreign_cache_guid(),
1964 "-2"); 1963 "-2");
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 EXPECT_FALSE(still_a_dir.GetIsUnappliedUpdate()); 2097 EXPECT_FALSE(still_a_dir.GetIsUnappliedUpdate());
2099 EXPECT_EQ(10u, still_a_dir.GetBaseVersion()); 2098 EXPECT_EQ(10u, still_a_dir.GetBaseVersion());
2100 EXPECT_EQ(10u, still_a_dir.GetServerVersion()); 2099 EXPECT_EQ(10u, still_a_dir.GetServerVersion());
2101 EXPECT_TRUE(still_a_dir.GetIsDir()); 2100 EXPECT_TRUE(still_a_dir.GetIsDir());
2102 2101
2103 Entry rename(&trans, GET_BY_ID, ids_.FromNumber(1)); 2102 Entry rename(&trans, GET_BY_ID, ids_.FromNumber(1));
2104 ASSERT_TRUE(rename.good()); 2103 ASSERT_TRUE(rename.good());
2105 EXPECT_EQ(root, rename.GetParentId()); 2104 EXPECT_EQ(root, rename.GetParentId());
2106 EXPECT_EQ("new_name", rename.GetNonUniqueName()); 2105 EXPECT_EQ("new_name", rename.GetNonUniqueName());
2107 EXPECT_FALSE(rename.GetIsUnappliedUpdate()); 2106 EXPECT_FALSE(rename.GetIsUnappliedUpdate());
2108 EXPECT_TRUE(ids_.FromNumber(1) == rename.GetId()); 2107 EXPECT_EQ(ids_.FromNumber(1), rename.GetId());
2109 EXPECT_EQ(20u, rename.GetBaseVersion()); 2108 EXPECT_EQ(20u, rename.GetBaseVersion());
2110 2109
2111 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); 2110 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2));
2112 ASSERT_TRUE(name_clash.good()); 2111 ASSERT_TRUE(name_clash.good());
2113 EXPECT_EQ(root, name_clash.GetParentId()); 2112 EXPECT_EQ(root, name_clash.GetParentId());
2114 EXPECT_TRUE(ids_.FromNumber(2) == name_clash.GetId()); 2113 EXPECT_EQ(ids_.FromNumber(2), name_clash.GetId());
2115 EXPECT_EQ(10u, name_clash.GetBaseVersion()); 2114 EXPECT_EQ(10u, name_clash.GetBaseVersion());
2116 EXPECT_EQ("in_root", name_clash.GetNonUniqueName()); 2115 EXPECT_EQ("in_root", name_clash.GetNonUniqueName());
2117 2116
2118 Entry ignored_old_version(&trans, GET_BY_ID, ids_.FromNumber(4)); 2117 Entry ignored_old_version(&trans, GET_BY_ID, ids_.FromNumber(4));
2119 ASSERT_TRUE(ignored_old_version.good()); 2118 ASSERT_TRUE(ignored_old_version.good());
2120 EXPECT_EQ("newer_version", ignored_old_version.GetNonUniqueName()); 2119 EXPECT_EQ("newer_version", ignored_old_version.GetNonUniqueName());
2121 EXPECT_FALSE(ignored_old_version.GetIsUnappliedUpdate()); 2120 EXPECT_FALSE(ignored_old_version.GetIsUnappliedUpdate());
2122 EXPECT_EQ(20u, ignored_old_version.GetBaseVersion()); 2121 EXPECT_EQ(20u, ignored_old_version.GetBaseVersion());
2123 2122
2124 Entry circular_parent_issue(&trans, GET_BY_ID, ids_.FromNumber(5)); 2123 Entry circular_parent_issue(&trans, GET_BY_ID, ids_.FromNumber(5));
(...skipping 3716 matching lines...) Expand 10 before | Expand all | Expand 10 after
5841 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 5840 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
5842 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 5841 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
5843 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 5842 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
5844 } else { 5843 } else {
5845 EXPECT_TRUE(final_monitor_records.empty()) 5844 EXPECT_TRUE(final_monitor_records.empty())
5846 << "Should not restore records after successful bookmark commit."; 5845 << "Should not restore records after successful bookmark commit.";
5847 } 5846 }
5848 } 5847 }
5849 5848
5850 } // namespace syncer 5849 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/sync_stopped_reporter_unittest.cc ('k') | components/sync/syncable/directory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698