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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 121123002: Update uses of UTF conversions in ppapi/, printing/, remoting/, rlz/, sandbox/, skia/, sql/, sync/,… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | « sql/statement.cc ('k') | sync/internal_api/write_node.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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // we'll use this spare folder later 346 // we'll use this spare folder later
347 WriteNode folder_node(&trans); 347 WriteNode folder_node(&trans);
348 EXPECT_TRUE(folder_node.InitBookmarkByCreation(root_node, NULL)); 348 EXPECT_TRUE(folder_node.InitBookmarkByCreation(root_node, NULL));
349 folder_id = folder_node.GetId(); 349 folder_id = folder_node.GetId();
350 350
351 WriteNode wnode(&trans); 351 WriteNode wnode(&trans);
352 WriteNode::InitUniqueByCreationResult result = 352 WriteNode::InitUniqueByCreationResult result =
353 wnode.InitUniqueByCreation(BOOKMARKS, root_node, "testtag"); 353 wnode.InitUniqueByCreation(BOOKMARKS, root_node, "testtag");
354 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 354 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
355 wnode.SetIsFolder(false); 355 wnode.SetIsFolder(false);
356 wnode.SetTitle(UTF8ToWide(test_title)); 356 wnode.SetTitle(base::UTF8ToWide(test_title));
357 357
358 node_id = wnode.GetId(); 358 node_id = wnode.GetId();
359 } 359 }
360 360
361 // Ensure we can delete something with a tag. 361 // Ensure we can delete something with a tag.
362 { 362 {
363 WriteTransaction trans(FROM_HERE, test_user_share_.user_share()); 363 WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
364 WriteNode wnode(&trans); 364 WriteNode wnode(&trans);
365 EXPECT_EQ(BaseNode::INIT_OK, 365 EXPECT_EQ(BaseNode::INIT_OK,
366 wnode.InitByClientTagLookup(BOOKMARKS, 366 wnode.InitByClientTagLookup(BOOKMARKS,
(...skipping 24 matching lines...) Expand all
391 391
392 WriteNode wnode(&trans); 392 WriteNode wnode(&trans);
393 // This will undelete the tag. 393 // This will undelete the tag.
394 WriteNode::InitUniqueByCreationResult result = 394 WriteNode::InitUniqueByCreationResult result =
395 wnode.InitUniqueByCreation(BOOKMARKS, folder_node, "testtag"); 395 wnode.InitUniqueByCreation(BOOKMARKS, folder_node, "testtag");
396 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 396 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
397 EXPECT_EQ(wnode.GetIsFolder(), false); 397 EXPECT_EQ(wnode.GetIsFolder(), false);
398 EXPECT_EQ(wnode.GetParentId(), folder_node.GetId()); 398 EXPECT_EQ(wnode.GetParentId(), folder_node.GetId());
399 EXPECT_EQ(wnode.GetId(), node_id); 399 EXPECT_EQ(wnode.GetId(), node_id);
400 EXPECT_NE(wnode.GetTitle(), test_title); // Title should be cleared 400 EXPECT_NE(wnode.GetTitle(), test_title); // Title should be cleared
401 wnode.SetTitle(UTF8ToWide(test_title)); 401 wnode.SetTitle(base::UTF8ToWide(test_title));
402 } 402 }
403 403
404 // Now look up should work. 404 // Now look up should work.
405 { 405 {
406 ReadTransaction trans(FROM_HERE, test_user_share_.user_share()); 406 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
407 ReadNode node(&trans); 407 ReadNode node(&trans);
408 EXPECT_EQ(BaseNode::INIT_OK, 408 EXPECT_EQ(BaseNode::INIT_OK,
409 node.InitByClientTagLookup(BOOKMARKS, 409 node.InitByClientTagLookup(BOOKMARKS,
410 "testtag")); 410 "testtag"));
411 EXPECT_EQ(node.GetTitle(), test_title); 411 EXPECT_EQ(node.GetTitle(), test_title);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 test_user_share_.encryption_handler()->EnableEncryptEverything(); 456 test_user_share_.encryption_handler()->EnableEncryptEverything();
457 int bookmark_id; 457 int bookmark_id;
458 { 458 {
459 WriteTransaction trans(FROM_HERE, test_user_share_.user_share()); 459 WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
460 ReadNode root_node(&trans); 460 ReadNode root_node(&trans);
461 root_node.InitByRootLookup(); 461 root_node.InitByRootLookup();
462 462
463 WriteNode bookmark_node(&trans); 463 WriteNode bookmark_node(&trans);
464 ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL)); 464 ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL));
465 bookmark_id = bookmark_node.GetId(); 465 bookmark_id = bookmark_node.GetId();
466 bookmark_node.SetTitle(UTF8ToWide("foo")); 466 bookmark_node.SetTitle(base::UTF8ToWide("foo"));
467 467
468 WriteNode pref_node(&trans); 468 WriteNode pref_node(&trans);
469 WriteNode::InitUniqueByCreationResult result = 469 WriteNode::InitUniqueByCreationResult result =
470 pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar"); 470 pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
471 ASSERT_EQ(WriteNode::INIT_SUCCESS, result); 471 ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
472 pref_node.SetTitle(UTF8ToWide("bar")); 472 pref_node.SetTitle(base::UTF8ToWide("bar"));
473 } 473 }
474 { 474 {
475 ReadTransaction trans(FROM_HERE, test_user_share_.user_share()); 475 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
476 ReadNode root_node(&trans); 476 ReadNode root_node(&trans);
477 root_node.InitByRootLookup(); 477 root_node.InitByRootLookup();
478 478
479 ReadNode bookmark_node(&trans); 479 ReadNode bookmark_node(&trans);
480 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id)); 480 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id));
481 EXPECT_EQ("foo", bookmark_node.GetTitle()); 481 EXPECT_EQ("foo", bookmark_node.GetTitle());
482 EXPECT_EQ(kEncryptedString, 482 EXPECT_EQ(kEncryptedString,
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 std::string title = "title"; 2116 std::string title = "title";
2117 std::string url = "url"; 2117 std::string url = "url";
2118 { 2118 {
2119 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2119 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2120 ReadNode bookmark_root(&trans); 2120 ReadNode bookmark_root(&trans);
2121 ASSERT_EQ(BaseNode::INIT_OK, 2121 ASSERT_EQ(BaseNode::INIT_OK,
2122 bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS))); 2122 bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
2123 WriteNode node(&trans); 2123 WriteNode node(&trans);
2124 ASSERT_TRUE(node.InitBookmarkByCreation(bookmark_root, NULL)); 2124 ASSERT_TRUE(node.InitBookmarkByCreation(bookmark_root, NULL));
2125 node.SetIsFolder(false); 2125 node.SetIsFolder(false);
2126 node.SetTitle(UTF8ToWide(title)); 2126 node.SetTitle(base::UTF8ToWide(title));
2127 2127
2128 sync_pb::BookmarkSpecifics bookmark_specifics(node.GetBookmarkSpecifics()); 2128 sync_pb::BookmarkSpecifics bookmark_specifics(node.GetBookmarkSpecifics());
2129 bookmark_specifics.set_url(url); 2129 bookmark_specifics.set_url(url);
2130 node.SetBookmarkSpecifics(bookmark_specifics); 2130 node.SetBookmarkSpecifics(bookmark_specifics);
2131 } 2131 }
2132 { 2132 {
2133 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2133 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2134 ReadNode bookmark_root(&trans); 2134 ReadNode bookmark_root(&trans);
2135 ASSERT_EQ(BaseNode::INIT_OK, 2135 ASSERT_EQ(BaseNode::INIT_OK,
2136 bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS))); 2136 bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 entity_specifics); 2455 entity_specifics);
2456 // New node shouldn't start off unsynced. 2456 // New node shouldn't start off unsynced.
2457 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2457 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2458 2458
2459 // Manually change to the same title. Should not set is_unsynced. 2459 // Manually change to the same title. Should not set is_unsynced.
2460 { 2460 {
2461 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2461 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2462 WriteNode node(&trans); 2462 WriteNode node(&trans);
2463 EXPECT_EQ(BaseNode::INIT_OK, 2463 EXPECT_EQ(BaseNode::INIT_OK,
2464 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2464 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2465 node.SetTitle(UTF8ToWide(client_tag)); 2465 node.SetTitle(base::UTF8ToWide(client_tag));
2466 } 2466 }
2467 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2467 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2468 2468
2469 // Manually change to new title. Should set is_unsynced. 2469 // Manually change to new title. Should set is_unsynced.
2470 { 2470 {
2471 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2471 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2472 WriteNode node(&trans); 2472 WriteNode node(&trans);
2473 EXPECT_EQ(BaseNode::INIT_OK, 2473 EXPECT_EQ(BaseNode::INIT_OK,
2474 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2474 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2475 node.SetTitle(UTF8ToWide("title2")); 2475 node.SetTitle(base::UTF8ToWide("title2"));
2476 } 2476 }
2477 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2477 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2478 } 2478 }
2479 2479
2480 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for encrypted 2480 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for encrypted
2481 // bookmarks when we write the same data, but does set it when we write new 2481 // bookmarks when we write the same data, but does set it when we write new
2482 // data. 2482 // data.
2483 TEST_F(SyncManagerTest, SetBookmarkTitleWithEncryption) { 2483 TEST_F(SyncManagerTest, SetBookmarkTitleWithEncryption) {
2484 std::string client_tag = "title"; 2484 std::string client_tag = "title";
2485 sync_pb::EntitySpecifics entity_specifics; 2485 sync_pb::EntitySpecifics entity_specifics;
(...skipping 18 matching lines...) Expand all
2504 PumpLoop(); 2504 PumpLoop();
2505 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2505 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2506 2506
2507 // Manually change to the same title. Should not set is_unsynced. 2507 // Manually change to the same title. Should not set is_unsynced.
2508 // NON_UNIQUE_NAME should be kEncryptedString. 2508 // NON_UNIQUE_NAME should be kEncryptedString.
2509 { 2509 {
2510 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2510 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2511 WriteNode node(&trans); 2511 WriteNode node(&trans);
2512 EXPECT_EQ(BaseNode::INIT_OK, 2512 EXPECT_EQ(BaseNode::INIT_OK,
2513 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2513 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2514 node.SetTitle(UTF8ToWide(client_tag)); 2514 node.SetTitle(base::UTF8ToWide(client_tag));
2515 const syncable::Entry* node_entry = node.GetEntry(); 2515 const syncable::Entry* node_entry = node.GetEntry();
2516 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics(); 2516 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics();
2517 EXPECT_TRUE(specifics.has_encrypted()); 2517 EXPECT_TRUE(specifics.has_encrypted());
2518 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName()); 2518 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName());
2519 } 2519 }
2520 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2520 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2521 2521
2522 // Manually change to new title. Should set is_unsynced. NON_UNIQUE_NAME 2522 // Manually change to new title. Should set is_unsynced. NON_UNIQUE_NAME
2523 // should still be kEncryptedString. 2523 // should still be kEncryptedString.
2524 { 2524 {
2525 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2525 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2526 WriteNode node(&trans); 2526 WriteNode node(&trans);
2527 EXPECT_EQ(BaseNode::INIT_OK, 2527 EXPECT_EQ(BaseNode::INIT_OK,
2528 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2528 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2529 node.SetTitle(UTF8ToWide("title2")); 2529 node.SetTitle(base::UTF8ToWide("title2"));
2530 const syncable::Entry* node_entry = node.GetEntry(); 2530 const syncable::Entry* node_entry = node.GetEntry();
2531 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics(); 2531 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics();
2532 EXPECT_TRUE(specifics.has_encrypted()); 2532 EXPECT_TRUE(specifics.has_encrypted());
2533 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName()); 2533 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName());
2534 } 2534 }
2535 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2535 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2536 } 2536 }
2537 2537
2538 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for non-bookmarks 2538 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for non-bookmarks
2539 // when we write the same data, but does set it when we write new data. 2539 // when we write the same data, but does set it when we write new data.
(...skipping 10 matching lines...) Expand all
2550 entity_specifics); 2550 entity_specifics);
2551 // New node shouldn't start off unsynced. 2551 // New node shouldn't start off unsynced.
2552 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2552 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2553 2553
2554 // Manually change to the same title. Should not set is_unsynced. 2554 // Manually change to the same title. Should not set is_unsynced.
2555 { 2555 {
2556 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2556 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2557 WriteNode node(&trans); 2557 WriteNode node(&trans);
2558 EXPECT_EQ(BaseNode::INIT_OK, 2558 EXPECT_EQ(BaseNode::INIT_OK,
2559 node.InitByClientTagLookup(PREFERENCES, client_tag)); 2559 node.InitByClientTagLookup(PREFERENCES, client_tag));
2560 node.SetTitle(UTF8ToWide(client_tag)); 2560 node.SetTitle(base::UTF8ToWide(client_tag));
2561 } 2561 }
2562 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2562 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2563 2563
2564 // Manually change to new title. Should set is_unsynced. 2564 // Manually change to new title. Should set is_unsynced.
2565 { 2565 {
2566 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2566 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2567 WriteNode node(&trans); 2567 WriteNode node(&trans);
2568 EXPECT_EQ(BaseNode::INIT_OK, 2568 EXPECT_EQ(BaseNode::INIT_OK,
2569 node.InitByClientTagLookup(PREFERENCES, client_tag)); 2569 node.InitByClientTagLookup(PREFERENCES, client_tag));
2570 node.SetTitle(UTF8ToWide("title2")); 2570 node.SetTitle(base::UTF8ToWide("title2"));
2571 } 2571 }
2572 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2572 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2573 } 2573 }
2574 2574
2575 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for encrypted 2575 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for encrypted
2576 // non-bookmarks when we write the same data or when we write new data 2576 // non-bookmarks when we write the same data or when we write new data
2577 // data (should remained kEncryptedString). 2577 // data (should remained kEncryptedString).
2578 TEST_F(SyncManagerTest, SetNonBookmarkTitleWithEncryption) { 2578 TEST_F(SyncManagerTest, SetNonBookmarkTitleWithEncryption) {
2579 std::string client_tag = "title"; 2579 std::string client_tag = "title";
2580 sync_pb::EntitySpecifics entity_specifics; 2580 sync_pb::EntitySpecifics entity_specifics;
(...skipping 20 matching lines...) Expand all
2601 PumpLoop(); 2601 PumpLoop();
2602 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2602 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2603 2603
2604 // Manually change to the same title. Should not set is_unsynced. 2604 // Manually change to the same title. Should not set is_unsynced.
2605 // NON_UNIQUE_NAME should be kEncryptedString. 2605 // NON_UNIQUE_NAME should be kEncryptedString.
2606 { 2606 {
2607 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2607 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2608 WriteNode node(&trans); 2608 WriteNode node(&trans);
2609 EXPECT_EQ(BaseNode::INIT_OK, 2609 EXPECT_EQ(BaseNode::INIT_OK,
2610 node.InitByClientTagLookup(PREFERENCES, client_tag)); 2610 node.InitByClientTagLookup(PREFERENCES, client_tag));
2611 node.SetTitle(UTF8ToWide(client_tag)); 2611 node.SetTitle(base::UTF8ToWide(client_tag));
2612 const syncable::Entry* node_entry = node.GetEntry(); 2612 const syncable::Entry* node_entry = node.GetEntry();
2613 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics(); 2613 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics();
2614 EXPECT_TRUE(specifics.has_encrypted()); 2614 EXPECT_TRUE(specifics.has_encrypted());
2615 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName()); 2615 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName());
2616 } 2616 }
2617 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2617 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2618 2618
2619 // Manually change to new title. Should not set is_unsynced because the 2619 // Manually change to new title. Should not set is_unsynced because the
2620 // NON_UNIQUE_NAME should still be kEncryptedString. 2620 // NON_UNIQUE_NAME should still be kEncryptedString.
2621 { 2621 {
2622 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2622 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2623 WriteNode node(&trans); 2623 WriteNode node(&trans);
2624 EXPECT_EQ(BaseNode::INIT_OK, 2624 EXPECT_EQ(BaseNode::INIT_OK,
2625 node.InitByClientTagLookup(PREFERENCES, client_tag)); 2625 node.InitByClientTagLookup(PREFERENCES, client_tag));
2626 node.SetTitle(UTF8ToWide("title2")); 2626 node.SetTitle(base::UTF8ToWide("title2"));
2627 const syncable::Entry* node_entry = node.GetEntry(); 2627 const syncable::Entry* node_entry = node.GetEntry();
2628 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics(); 2628 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics();
2629 EXPECT_TRUE(specifics.has_encrypted()); 2629 EXPECT_TRUE(specifics.has_encrypted());
2630 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName()); 2630 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName());
2631 EXPECT_FALSE(node_entry->GetIsUnsynced()); 2631 EXPECT_FALSE(node_entry->GetIsUnsynced());
2632 } 2632 }
2633 } 2633 }
2634 2634
2635 // Ensure that titles are truncated to 255 bytes, and attempting to reset 2635 // Ensure that titles are truncated to 255 bytes, and attempting to reset
2636 // them to their longer version does not set IS_UNSYNCED. 2636 // them to their longer version does not set IS_UNSYNCED.
(...skipping 12 matching lines...) Expand all
2649 entity_specifics); 2649 entity_specifics);
2650 // New node shouldn't start off unsynced. 2650 // New node shouldn't start off unsynced.
2651 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, kClientTag)); 2651 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, kClientTag));
2652 2652
2653 // Manually change to the long title. Should set is_unsynced. 2653 // Manually change to the long title. Should set is_unsynced.
2654 { 2654 {
2655 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2655 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2656 WriteNode node(&trans); 2656 WriteNode node(&trans);
2657 EXPECT_EQ(BaseNode::INIT_OK, 2657 EXPECT_EQ(BaseNode::INIT_OK,
2658 node.InitByClientTagLookup(PREFERENCES, kClientTag)); 2658 node.InitByClientTagLookup(PREFERENCES, kClientTag));
2659 node.SetTitle(UTF8ToWide(title)); 2659 node.SetTitle(base::UTF8ToWide(title));
2660 EXPECT_EQ(node.GetTitle(), title.substr(0, 255)); 2660 EXPECT_EQ(node.GetTitle(), title.substr(0, 255));
2661 } 2661 }
2662 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, kClientTag)); 2662 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, kClientTag));
2663 2663
2664 // Manually change to the same title. Should not set is_unsynced. 2664 // Manually change to the same title. Should not set is_unsynced.
2665 { 2665 {
2666 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2666 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2667 WriteNode node(&trans); 2667 WriteNode node(&trans);
2668 EXPECT_EQ(BaseNode::INIT_OK, 2668 EXPECT_EQ(BaseNode::INIT_OK,
2669 node.InitByClientTagLookup(PREFERENCES, kClientTag)); 2669 node.InitByClientTagLookup(PREFERENCES, kClientTag));
2670 node.SetTitle(UTF8ToWide(title)); 2670 node.SetTitle(base::UTF8ToWide(title));
2671 EXPECT_EQ(node.GetTitle(), title.substr(0, 255)); 2671 EXPECT_EQ(node.GetTitle(), title.substr(0, 255));
2672 } 2672 }
2673 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, kClientTag)); 2673 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, kClientTag));
2674 2674
2675 // Manually change to new title. Should set is_unsynced. 2675 // Manually change to new title. Should set is_unsynced.
2676 { 2676 {
2677 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2677 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2678 WriteNode node(&trans); 2678 WriteNode node(&trans);
2679 EXPECT_EQ(BaseNode::INIT_OK, 2679 EXPECT_EQ(BaseNode::INIT_OK,
2680 node.InitByClientTagLookup(PREFERENCES, kClientTag)); 2680 node.InitByClientTagLookup(PREFERENCES, kClientTag));
2681 node.SetTitle(UTF8ToWide("title2")); 2681 node.SetTitle(base::UTF8ToWide("title2"));
2682 } 2682 }
2683 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, kClientTag)); 2683 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, kClientTag));
2684 } 2684 }
2685 2685
2686 // Create an encrypted entry when the cryptographer doesn't think the type is 2686 // Create an encrypted entry when the cryptographer doesn't think the type is
2687 // marked for encryption. Ensure reads/writes don't break and don't unencrypt 2687 // marked for encryption. Ensure reads/writes don't break and don't unencrypt
2688 // the data. 2688 // the data.
2689 TEST_F(SyncManagerTest, SetPreviouslyEncryptedSpecifics) { 2689 TEST_F(SyncManagerTest, SetPreviouslyEncryptedSpecifics) {
2690 std::string client_tag = "tag"; 2690 std::string client_tag = "tag";
2691 std::string url = "url"; 2691 std::string url = "url";
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 // SyncManagerInitInvalidStorageTest::GetFactory will return 3511 // SyncManagerInitInvalidStorageTest::GetFactory will return
3512 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3512 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3513 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3513 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3514 // task is to ensure that SyncManagerImpl reported initialization failure in 3514 // task is to ensure that SyncManagerImpl reported initialization failure in
3515 // OnInitializationComplete callback. 3515 // OnInitializationComplete callback.
3516 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3516 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3517 EXPECT_FALSE(initialization_succeeded_); 3517 EXPECT_FALSE(initialization_succeeded_);
3518 } 3518 }
3519 3519
3520 } // namespace 3520 } // namespace
OLDNEW
« no previous file with comments | « sql/statement.cc ('k') | sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698