Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sync / glue / chrome_encryptor_unittest.cc
blob0a2c17b130ff8b3b69041288977585f6f01f3fd0
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/sync/glue/chrome_encryptor.h"
6 #include "components/webdata/encryptor/encryptor.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace browser_sync {
11 namespace {
13 const char kPlaintext[] = "The Magic Words are Squeamish Ossifrage";
15 class ChromeEncryptorTest : public testing::Test {
16 protected:
17 ChromeEncryptor encryptor_;
20 TEST_F(ChromeEncryptorTest, EncryptDecrypt) {
21 #if defined(OS_MACOSX)
22 // ChromeEncryptor ends up needing access to the keychain on OS X,
23 // so use the mock keychain to prevent prompts.
24 ::Encryptor::UseMockKeychain(true);
25 #endif
26 std::string ciphertext;
27 EXPECT_TRUE(encryptor_.EncryptString(kPlaintext, &ciphertext));
28 EXPECT_NE(kPlaintext, ciphertext);
29 std::string plaintext;
30 EXPECT_TRUE(encryptor_.DecryptString(ciphertext, &plaintext));
31 EXPECT_EQ(kPlaintext, plaintext);
34 } // namespace
36 } // namespace browser_sync