Commit bf2d51dd authored by akalin@chromium.org's avatar akalin@chromium.org

[Sync] Add unit tests for ChromeEncryptor

BUG=116607
TEST=


Review URL: http://codereview.chromium.org/9580027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124892 0039d316-1c4b-4281-b951-d872f2087c98
parent bd493ca1
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/password_manager/encryptor.h"
#include "chrome/browser/sync/glue/chrome_encryptor.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace browser_sync {
namespace {
const char kPlaintext[] = "The Magic Words are Squeamish Ossifrage";
class ChromeEncryptorTest : public testing::Test {
protected:
ChromeEncryptor encryptor_;
};
TEST_F(ChromeEncryptorTest, EncryptDecrypt) {
#if defined(OS_MACOSX)
// ChromeEncryptor ends up needing access to the keychain on OS X,
// so use the mock keychain to prevent prompts.
::Encryptor::UseMockKeychain(true);
#endif
std::string ciphertext;
EXPECT_TRUE(encryptor_.EncryptString(kPlaintext, &ciphertext));
EXPECT_NE(kPlaintext, ciphertext);
std::string plaintext;
EXPECT_TRUE(encryptor_.DecryptString(ciphertext, &plaintext));
EXPECT_EQ(kPlaintext, plaintext);
}
} // namespace
} // namespace browser_sync
...@@ -1733,6 +1733,7 @@ ...@@ -1733,6 +1733,7 @@
'browser/sync/glue/browser_thread_model_worker_unittest.cc', 'browser/sync/glue/browser_thread_model_worker_unittest.cc',
'browser/sync/glue/change_processor_mock.cc', 'browser/sync/glue/change_processor_mock.cc',
'browser/sync/glue/change_processor_mock.h', 'browser/sync/glue/change_processor_mock.h',
'browser/sync/glue/chrome_encryptor_unittest.cc',
'browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc', 'browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc',
'browser/sync/glue/chrome_sync_notification_bridge_unittest.cc', 'browser/sync/glue/chrome_sync_notification_bridge_unittest.cc',
'browser/sync/glue/data_type_controller_mock.cc', 'browser/sync/glue/data_type_controller_mock.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment