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

Side by Side Diff: chrome/browser/sync/internal_api/syncapi_unittest.cc

Issue 7981006: [Sync] use base::Time in sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux compile errors Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 43 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
44 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 44 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
45 #include "chrome/browser/sync/protocol/proto_value_conversions.h" 45 #include "chrome/browser/sync/protocol/proto_value_conversions.h"
46 #include "chrome/browser/sync/protocol/sync.pb.h" 46 #include "chrome/browser/sync/protocol/sync.pb.h"
47 #include "chrome/browser/sync/sessions/sync_session.h" 47 #include "chrome/browser/sync/sessions/sync_session.h"
48 #include "chrome/browser/sync/syncable/directory_manager.h" 48 #include "chrome/browser/sync/syncable/directory_manager.h"
49 #include "chrome/browser/sync/syncable/syncable.h" 49 #include "chrome/browser/sync/syncable/syncable.h"
50 #include "chrome/browser/sync/syncable/syncable_id.h" 50 #include "chrome/browser/sync/syncable/syncable_id.h"
51 #include "chrome/browser/sync/test/engine/test_user_share.h" 51 #include "chrome/browser/sync/test/engine/test_user_share.h"
52 #include "chrome/browser/sync/util/cryptographer.h" 52 #include "chrome/browser/sync/util/cryptographer.h"
53 #include "chrome/browser/sync/util/time.h"
53 #include "chrome/test/base/values_test_util.h" 54 #include "chrome/test/base/values_test_util.h"
54 #include "content/browser/browser_thread.h" 55 #include "content/browser/browser_thread.h"
55 #include "testing/gmock/include/gmock/gmock.h" 56 #include "testing/gmock/include/gmock/gmock.h"
56 #include "testing/gtest/include/gtest/gtest.h" 57 #include "testing/gtest/include/gtest/gtest.h"
57 58
58 using browser_sync::Cryptographer; 59 using browser_sync::Cryptographer;
59 using browser_sync::HasArgsAsList; 60 using browser_sync::HasArgsAsList;
60 using browser_sync::HasDetailsAsDictionary; 61 using browser_sync::HasDetailsAsDictionary;
61 using browser_sync::KeyParams; 62 using browser_sync::KeyParams;
62 using browser_sync::JsArgList; 63 using browser_sync::JsArgList;
(...skipping 26 matching lines...) Expand all
89 90
90 void ExpectInt64Value(int64 expected_value, 91 void ExpectInt64Value(int64 expected_value,
91 const DictionaryValue& value, const std::string& key) { 92 const DictionaryValue& value, const std::string& key) {
92 std::string int64_str; 93 std::string int64_str;
93 EXPECT_TRUE(value.GetString(key, &int64_str)); 94 EXPECT_TRUE(value.GetString(key, &int64_str));
94 int64 val = 0; 95 int64 val = 0;
95 EXPECT_TRUE(base::StringToInt64(int64_str, &val)); 96 EXPECT_TRUE(base::StringToInt64(int64_str, &val));
96 EXPECT_EQ(expected_value, val); 97 EXPECT_EQ(expected_value, val);
97 } 98 }
98 99
100 void ExpectTimeValue(const base::Time& expected_value,
101 const DictionaryValue& value, const std::string& key) {
102 std::string time_str;
103 EXPECT_TRUE(value.GetString(key, &time_str));
104 EXPECT_EQ(browser_sync::GetTimeDebugString(expected_value), time_str);
105 }
106
99 // Makes a non-folder child of the root node. Returns the id of the 107 // Makes a non-folder child of the root node. Returns the id of the
100 // newly-created node. 108 // newly-created node.
101 int64 MakeNode(UserShare* share, 109 int64 MakeNode(UserShare* share,
102 ModelType model_type, 110 ModelType model_type,
103 const std::string& client_tag) { 111 const std::string& client_tag) {
104 WriteTransaction trans(FROM_HERE, share); 112 WriteTransaction trans(FROM_HERE, share);
105 ReadNode root_node(&trans); 113 ReadNode root_node(&trans);
106 root_node.InitByRootLookup(); 114 root_node.InitByRootLookup();
107 WriteNode node(&trans); 115 WriteNode node(&trans);
108 EXPECT_TRUE(node.InitUniqueByCreation(model_type, root_node, client_tag)); 116 EXPECT_TRUE(node.InitUniqueByCreation(model_type, root_node, client_tag));
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 } else if (expected_model_type == syncable::TOP_LEVEL_FOLDER) { 514 } else if (expected_model_type == syncable::TOP_LEVEL_FOLDER) {
507 EXPECT_EQ("Top-level folder", type_str); 515 EXPECT_EQ("Top-level folder", type_str);
508 } else if (expected_model_type == syncable::UNSPECIFIED) { 516 } else if (expected_model_type == syncable::UNSPECIFIED) {
509 EXPECT_EQ("Unspecified", type_str); 517 EXPECT_EQ("Unspecified", type_str);
510 } else { 518 } else {
511 ADD_FAILURE(); 519 ADD_FAILURE();
512 } 520 }
513 } 521 }
514 if (is_detailed) { 522 if (is_detailed) {
515 ExpectInt64Value(node.GetParentId(), value, "parentId"); 523 ExpectInt64Value(node.GetParentId(), value, "parentId");
516 ExpectInt64Value(node.GetModificationTime(), value, "modificationTime"); 524 ExpectTimeValue(node.GetModificationTime(), value, "modificationTime");
517 ExpectInt64Value(node.GetExternalId(), value, "externalId"); 525 ExpectInt64Value(node.GetExternalId(), value, "externalId");
518 ExpectInt64Value(node.GetPredecessorId(), value, "predecessorId"); 526 ExpectInt64Value(node.GetPredecessorId(), value, "predecessorId");
519 ExpectInt64Value(node.GetSuccessorId(), value, "successorId"); 527 ExpectInt64Value(node.GetSuccessorId(), value, "successorId");
520 ExpectInt64Value(node.GetFirstChildId(), value, "firstChildId"); 528 ExpectInt64Value(node.GetFirstChildId(), value, "firstChildId");
521 { 529 {
522 scoped_ptr<DictionaryValue> expected_entry(node.GetEntry()->ToValue()); 530 scoped_ptr<DictionaryValue> expected_entry(node.GetEntry()->ToValue());
523 Value* entry = NULL; 531 Value* entry = NULL;
524 EXPECT_TRUE(value.Get("entry", &entry)); 532 EXPECT_TRUE(value.Get("entry", &entry));
525 EXPECT_TRUE(Value::Equals(entry, expected_entry.get())); 533 EXPECT_TRUE(Value::Equals(entry, expected_entry.get()));
526 } 534 }
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 EXPECT_EQ(syncable::BOOKMARKS, node2.GetModelType()); 1458 EXPECT_EQ(syncable::BOOKMARKS, node2.GetModelType());
1451 // We should de-canonicalize the title in GetTitle(), but the title in the 1459 // We should de-canonicalize the title in GetTitle(), but the title in the
1452 // specifics should be stored in the server legal form. 1460 // specifics should be stored in the server legal form.
1453 EXPECT_EQ(raw_title2, node2.GetTitle()); 1461 EXPECT_EQ(raw_title2, node2.GetTitle());
1454 EXPECT_EQ(title2, node2.GetBookmarkSpecifics().title()); 1462 EXPECT_EQ(title2, node2.GetBookmarkSpecifics().title());
1455 EXPECT_EQ(url2, node2.GetBookmarkSpecifics().url()); 1463 EXPECT_EQ(url2, node2.GetBookmarkSpecifics().url());
1456 } 1464 }
1457 } 1465 }
1458 1466
1459 } // namespace browser_sync 1467 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/base_node.cc ('k') | chrome/browser/sync/profile_sync_service_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698