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