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

Side by Side Diff: chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc

Issue 1220963005: Update base::StartsWith calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sessions/sessions_sync_manager.h" 5 #include "chrome/browser/sync/sessions/sessions_sync_manager.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/sessions/session_tab_helper.h" 9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/sync/glue/session_sync_test_helper.h" 10 #include "chrome/browser/sync/glue/session_sync_test_helper.h"
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 EXPECT_TRUE(specifics.has_header()); 1038 EXPECT_TRUE(specifics.has_header());
1039 const sync_pb::SessionHeader& header_s = specifics.header(); 1039 const sync_pb::SessionHeader& header_s = specifics.header();
1040 EXPECT_TRUE(header_s.has_device_type()); 1040 EXPECT_TRUE(header_s.has_device_type());
1041 EXPECT_EQ(GetLocalDeviceInfo()->client_name(), header_s.client_name()); 1041 EXPECT_EQ(GetLocalDeviceInfo()->client_name(), header_s.client_name());
1042 EXPECT_EQ(0, header_s.window_size()); 1042 EXPECT_EQ(0, header_s.window_size());
1043 1043
1044 // Verify the tab node creations and updates with content. 1044 // Verify the tab node creations and updates with content.
1045 for (int i = 1; i < 3; i++) { 1045 for (int i = 1; i < 3; i++) {
1046 EXPECT_TRUE(output[i].IsValid()); 1046 EXPECT_TRUE(output[i].IsValid());
1047 const SyncData data(output[i].sync_data()); 1047 const SyncData data(output[i].sync_data());
1048 EXPECT_TRUE(base::StartsWithASCII(syncer::SyncDataLocal(data).GetTag(), 1048 EXPECT_TRUE(base::StartsWith(syncer::SyncDataLocal(data).GetTag(),
1049 manager()->current_machine_tag(), true)); 1049 manager()->current_machine_tag(),
1050 base::CompareCase::SENSITIVE));
1050 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session()); 1051 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session());
1051 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag()); 1052 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag());
1052 } 1053 }
1053 EXPECT_EQ(SyncChange::ACTION_ADD, output[1].change_type()); 1054 EXPECT_EQ(SyncChange::ACTION_ADD, output[1].change_type());
1054 EXPECT_EQ(SyncChange::ACTION_UPDATE, output[2].change_type()); 1055 EXPECT_EQ(SyncChange::ACTION_UPDATE, output[2].change_type());
1055 EXPECT_TRUE(output[2].sync_data().GetSpecifics().session().has_tab()); 1056 EXPECT_TRUE(output[2].sync_data().GetSpecifics().session().has_tab());
1056 1057
1057 // Verify the header was updated to reflect window state. 1058 // Verify the header was updated to reflect window state.
1058 EXPECT_TRUE(output[3].IsValid()); 1059 EXPECT_TRUE(output[3].IsValid());
1059 EXPECT_EQ(SyncChange::ACTION_UPDATE, output[3].change_type()); 1060 EXPECT_EQ(SyncChange::ACTION_UPDATE, output[3].change_type());
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 0, 1473 0,
1473 out[1].sync_data().GetSpecifics().session().header().window_size()); 1474 out[1].sync_data().GetSpecifics().session().header().window_size());
1474 out.clear(); 1475 out.clear();
1475 1476
1476 // Go to a sync-interesting URL. 1477 // Go to a sync-interesting URL.
1477 NavigateAndCommitActiveTab(GURL("http://foo2")); 1478 NavigateAndCommitActiveTab(GURL("http://foo2"));
1478 1479
1479 EXPECT_EQ(3U, out.size()); // Tab add, update, and header update. 1480 EXPECT_EQ(3U, out.size()); // Tab add, update, and header update.
1480 1481
1481 EXPECT_TRUE( 1482 EXPECT_TRUE(
1482 base::StartsWithASCII(syncer::SyncDataLocal(out[0].sync_data()).GetTag(), 1483 base::StartsWith(syncer::SyncDataLocal(out[0].sync_data()).GetTag(),
1483 manager()->current_machine_tag(), true)); 1484 manager()->current_machine_tag(),
1485 base::CompareCase::SENSITIVE));
1484 EXPECT_EQ(manager()->current_machine_tag(), 1486 EXPECT_EQ(manager()->current_machine_tag(),
1485 out[0].sync_data().GetSpecifics().session().session_tag()); 1487 out[0].sync_data().GetSpecifics().session().session_tag());
1486 EXPECT_EQ(SyncChange::ACTION_ADD, out[0].change_type()); 1488 EXPECT_EQ(SyncChange::ACTION_ADD, out[0].change_type());
1487 1489
1488 EXPECT_TRUE( 1490 EXPECT_TRUE(
1489 base::StartsWithASCII(syncer::SyncDataLocal(out[1].sync_data()).GetTag(), 1491 base::StartsWith(syncer::SyncDataLocal(out[1].sync_data()).GetTag(),
1490 manager()->current_machine_tag(), true)); 1492 manager()->current_machine_tag(),
1493 base::CompareCase::SENSITIVE));
1491 EXPECT_EQ(manager()->current_machine_tag(), 1494 EXPECT_EQ(manager()->current_machine_tag(),
1492 out[1].sync_data().GetSpecifics().session().session_tag()); 1495 out[1].sync_data().GetSpecifics().session().session_tag());
1493 EXPECT_TRUE(out[1].sync_data().GetSpecifics().session().has_tab()); 1496 EXPECT_TRUE(out[1].sync_data().GetSpecifics().session().has_tab());
1494 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[1].change_type()); 1497 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[1].change_type());
1495 1498
1496 EXPECT_TRUE(out[2].IsValid()); 1499 EXPECT_TRUE(out[2].IsValid());
1497 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[2].change_type()); 1500 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[2].change_type());
1498 const SyncData data(out[2].sync_data()); 1501 const SyncData data(out[2].sync_data());
1499 EXPECT_EQ(manager()->current_machine_tag(), 1502 EXPECT_EQ(manager()->current_machine_tag(),
1500 syncer::SyncDataLocal(data).GetTag()); 1503 syncer::SyncDataLocal(data).GetTag());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 // = 6 total header updates. 1537 // = 6 total header updates.
1535 // 12 total updates. 1538 // 12 total updates.
1536 ASSERT_EQ(12U, out.size()); 1539 ASSERT_EQ(12U, out.size());
1537 1540
1538 // Verify the tab node creations and updates to ensure the SyncProcessor 1541 // Verify the tab node creations and updates to ensure the SyncProcessor
1539 // sees the right operations. 1542 // sees the right operations.
1540 for (int i = 0; i < 12; i++) { 1543 for (int i = 0; i < 12; i++) {
1541 SCOPED_TRACE(i); 1544 SCOPED_TRACE(i);
1542 EXPECT_TRUE(out[i].IsValid()); 1545 EXPECT_TRUE(out[i].IsValid());
1543 const SyncData data(out[i].sync_data()); 1546 const SyncData data(out[i].sync_data());
1544 EXPECT_TRUE(base::StartsWithASCII(syncer::SyncDataLocal(data).GetTag(), 1547 EXPECT_TRUE(base::StartsWith(syncer::SyncDataLocal(data).GetTag(),
1545 manager()->current_machine_tag(), true)); 1548 manager()->current_machine_tag(),
1549 base::CompareCase::SENSITIVE));
1546 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session()); 1550 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session());
1547 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag()); 1551 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag());
1548 if (i % 6 == 0) { 1552 if (i % 6 == 0) {
1549 // First thing on an AddTab is a no-op header update for parented tab. 1553 // First thing on an AddTab is a no-op header update for parented tab.
1550 EXPECT_EQ(header.SerializeAsString(), 1554 EXPECT_EQ(header.SerializeAsString(),
1551 data.GetSpecifics().SerializeAsString()); 1555 data.GetSpecifics().SerializeAsString());
1552 EXPECT_EQ(manager()->current_machine_tag(), 1556 EXPECT_EQ(manager()->current_machine_tag(),
1553 syncer::SyncDataLocal(data).GetTag()); 1557 syncer::SyncDataLocal(data).GetTag());
1554 } else if (i % 6 == 1) { 1558 } else if (i % 6 == 1) {
1555 // Next, the TabNodePool should create the tab node. 1559 // Next, the TabNodePool should create the tab node.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 EXPECT_TRUE(specifics.has_header()); 1646 EXPECT_TRUE(specifics.has_header());
1643 const sync_pb::SessionHeader& header_s = specifics.header(); 1647 const sync_pb::SessionHeader& header_s = specifics.header();
1644 EXPECT_TRUE(header_s.has_device_type()); 1648 EXPECT_TRUE(header_s.has_device_type());
1645 EXPECT_EQ(GetLocalDeviceInfo()->client_name(), header_s.client_name()); 1649 EXPECT_EQ(GetLocalDeviceInfo()->client_name(), header_s.client_name());
1646 EXPECT_EQ(0, header_s.window_size()); 1650 EXPECT_EQ(0, header_s.window_size());
1647 1651
1648 // Verify the tab node creations and updates with content. 1652 // Verify the tab node creations and updates with content.
1649 for (int i = 1; i < 5; i++) { 1653 for (int i = 1; i < 5; i++) {
1650 EXPECT_TRUE(out[i].IsValid()); 1654 EXPECT_TRUE(out[i].IsValid());
1651 const SyncData data(out[i].sync_data()); 1655 const SyncData data(out[i].sync_data());
1652 EXPECT_TRUE(base::StartsWithASCII(syncer::SyncDataLocal(data).GetTag(), 1656 EXPECT_TRUE(base::StartsWith(syncer::SyncDataLocal(data).GetTag(),
1653 manager()->current_machine_tag(), true)); 1657 manager()->current_machine_tag(),
1658 base::CompareCase::SENSITIVE));
1654 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session()); 1659 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session());
1655 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag()); 1660 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag());
1656 if (i % 2 == 1) { 1661 if (i % 2 == 1) {
1657 EXPECT_EQ(SyncChange::ACTION_ADD, out[i].change_type()); 1662 EXPECT_EQ(SyncChange::ACTION_ADD, out[i].change_type());
1658 } else { 1663 } else {
1659 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); 1664 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type());
1660 EXPECT_TRUE(specifics.has_tab()); 1665 EXPECT_TRUE(specifics.has_tab());
1661 } 1666 }
1662 } 1667 }
1663 1668
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 ASSERT_EQ(3U, window_tabs.size()); 2121 ASSERT_EQ(3U, window_tabs.size());
2117 // The first one is from the original set of tabs. 2122 // The first one is from the original set of tabs.
2118 ASSERT_EQ(1, window_tabs[0]->tab_visual_index); 2123 ASSERT_EQ(1, window_tabs[0]->tab_visual_index);
2119 // The one from the original set of tabs wins over duplicating_tab1. 2124 // The one from the original set of tabs wins over duplicating_tab1.
2120 ASSERT_EQ(1, window_tabs[1]->tab_visual_index); 2125 ASSERT_EQ(1, window_tabs[1]->tab_visual_index);
2121 // duplicating_tab2 wins due to the later timestamp. 2126 // duplicating_tab2 wins due to the later timestamp.
2122 ASSERT_EQ(3, window_tabs[2]->tab_visual_index); 2127 ASSERT_EQ(3, window_tabs[2]->tab_visual_index);
2123 } 2128 }
2124 2129
2125 } // namespace browser_sync 2130 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698