Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: chrome/browser/sync/glue/chrome_encryptor_unittest.cc

Issue 9580027: [Sync] Add unit tests for ChromeEncryptor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittests on OS X Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/chrome_encryptor_unittest.cc
diff --git a/chrome/browser/sync/glue/chrome_encryptor_unittest.cc b/chrome/browser/sync/glue/chrome_encryptor_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0a04c04755cba2df298e71eefa7af760b05fdb97
--- /dev/null
+++ b/chrome/browser/sync/glue/chrome_encryptor_unittest.cc
@@ -0,0 +1,36 @@
+// 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
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698