- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / glue / chrome_encryptor_unittest.cc
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.
4
5 #include "chrome/browser/sync/glue/chrome_encryptor.h"
6 #include "components/webdata/encryptor/encryptor.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace browser_sync {
10
11 namespace {
12
13 const char kPlaintext[] = "The Magic Words are Squeamish Ossifrage";
14
15 class ChromeEncryptorTest : public testing::Test {
16  protected:
17   ChromeEncryptor encryptor_;
18 };
19
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);
32 }
33
34 }  // namespace
35
36 }  // namespace browser_sync