OLD | NEW |
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 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 5 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
| 6 #include "chrome/browser/sync/protocol/sync.pb.h" |
6 #include "chrome/browser/sync/util/cryptographer.h" | 7 #include "chrome/browser/sync/util/cryptographer.h" |
7 #include "chrome/browser/sync/engine/nigori_util.h" | 8 #include "chrome/browser/sync/engine/nigori_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace syncable { | 11 namespace syncable { |
11 | 12 |
12 typedef testing::Test NigoriUtilTest; | 13 typedef testing::Test NigoriUtilTest; |
13 | 14 |
14 TEST(NigoriUtilTest, SpecificsNeedsEncryption) { | 15 TEST(NigoriUtilTest, SpecificsNeedsEncryption) { |
15 ModelTypeSet encrypted_types; | 16 ModelTypeSet encrypted_types; |
16 encrypted_types.Put(BOOKMARKS); | 17 encrypted_types.Put(BOOKMARKS); |
17 encrypted_types.Put(PASSWORDS); | 18 encrypted_types.Put(PASSWORDS); |
18 | 19 |
19 sync_pb::EntitySpecifics specifics; | 20 sync_pb::EntitySpecifics specifics; |
20 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), specifics)); | 21 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), specifics)); |
21 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics)); | 22 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics)); |
22 | 23 |
23 AddDefaultExtensionValue(PREFERENCES, &specifics); | 24 AddDefaultFieldValue(PREFERENCES, &specifics); |
24 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics)); | 25 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics)); |
25 | 26 |
26 sync_pb::EntitySpecifics bookmark_specifics; | 27 sync_pb::EntitySpecifics bookmark_specifics; |
27 AddDefaultExtensionValue(BOOKMARKS, &bookmark_specifics); | 28 AddDefaultFieldValue(BOOKMARKS, &bookmark_specifics); |
28 EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); | 29 EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); |
29 | 30 |
30 bookmark_specifics.MutableExtension(sync_pb::bookmark)->set_title("title"); | 31 bookmark_specifics.mutable_bookmark()->set_title("title"); |
31 bookmark_specifics.MutableExtension(sync_pb::bookmark)->set_url("url"); | 32 bookmark_specifics.mutable_bookmark()->set_url("url"); |
32 EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); | 33 EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); |
33 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics)); | 34 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics)); |
34 | 35 |
35 bookmark_specifics.mutable_encrypted(); | 36 bookmark_specifics.mutable_encrypted(); |
36 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); | 37 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); |
37 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics)); | 38 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics)); |
38 | 39 |
39 sync_pb::EntitySpecifics password_specifics; | 40 sync_pb::EntitySpecifics password_specifics; |
40 AddDefaultExtensionValue(PASSWORDS, &password_specifics); | 41 AddDefaultFieldValue(PASSWORDS, &password_specifics); |
41 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, password_specifics)); | 42 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, password_specifics)); |
42 } | 43 } |
43 | 44 |
44 // ProcessUnsyncedChangesForEncryption and other methods that rely on the syncer | 45 // ProcessUnsyncedChangesForEncryption and other methods that rely on the syncer |
45 // are tested in apply_updates_command_unittest.cc | 46 // are tested in apply_updates_command_unittest.cc |
46 | 47 |
47 } // namespace syncable | 48 } // namespace syncable |
OLD | NEW |