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

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

Issue 2828021: Take 2: sync changes to support encryption (Closed)
Patch Set: fix flaky password test under valgrind Created 10 years, 6 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.cc ('k') | chrome/browser/sync/engine/syncer_util.h » ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "chrome/browser/sync/engine/syncapi.h" 11 #include "chrome/browser/sync/engine/syncapi.h"
12 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
12 #include "chrome/browser/sync/syncable/directory_manager.h" 13 #include "chrome/browser/sync/syncable/directory_manager.h"
13 #include "chrome/browser/sync/syncable/syncable.h" 14 #include "chrome/browser/sync/syncable/syncable.h"
14 #include "chrome/test/sync/engine/test_directory_setter_upper.h" 15 #include "chrome/test/sync/engine/test_directory_setter_upper.h"
15 16
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
19 using browser_sync::KeyParams;
20
18 namespace sync_api { 21 namespace sync_api {
19 22
20 class SyncApiTest : public testing::Test { 23 class SyncApiTest : public testing::Test {
21 public: 24 public:
22 virtual void SetUp() { 25 virtual void SetUp() {
23 setter_upper_.SetUp(); 26 setter_upper_.SetUp();
24 share_.dir_manager.reset(setter_upper_.manager()); 27 share_.dir_manager.reset(setter_upper_.manager());
25 share_.authenticated_name = setter_upper_.name(); 28 share_.authenticated_name = setter_upper_.name();
26 } 29 }
27 30
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 { 228 {
226 ReadTransaction trans(&share_); 229 ReadTransaction trans(&share_);
227 ReadNode node(&trans); 230 ReadNode node(&trans);
228 EXPECT_TRUE(node.InitByClientTagLookup(syncable::BOOKMARKS, 231 EXPECT_TRUE(node.InitByClientTagLookup(syncable::BOOKMARKS,
229 "testtag")); 232 "testtag"));
230 EXPECT_EQ(node.GetTitle(), test_title); 233 EXPECT_EQ(node.GetTitle(), test_title);
231 EXPECT_EQ(node.GetModelType(), syncable::BOOKMARKS); 234 EXPECT_EQ(node.GetModelType(), syncable::BOOKMARKS);
232 } 235 }
233 } 236 }
234 237
238 TEST_F(SyncApiTest, WriteAndReadPassword) {
239 KeyParams params = {"localhost", "username", "passphrase"};
240 share_.dir_manager->cryptographer()->AddKey(params);
241 {
242 WriteTransaction trans(&share_);
243 ReadNode root_node(&trans);
244 root_node.InitByRootLookup();
245
246 WriteNode password_node(&trans);
247 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS,
248 root_node, "foo"));
249 sync_pb::PasswordSpecificsData data;
250 data.set_password_value("secret");
251 password_node.SetPasswordSpecifics(data);
252 }
253 {
254 ReadTransaction trans(&share_);
255 ReadNode root_node(&trans);
256 root_node.InitByRootLookup();
257
258 ReadNode password_node(&trans);
259 EXPECT_TRUE(password_node.InitByClientTagLookup(syncable::PASSWORDS,
260 "foo"));
261 const sync_pb::PasswordSpecificsData& data =
262 password_node.GetPasswordSpecifics();
263 EXPECT_EQ("secret", data.password_value());
264 }
265 }
266
235 } // namespace browser_sync 267 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.cc ('k') | chrome/browser/sync/engine/syncer_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698