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