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

Unified Diff: chrome/browser/ui/crypto_module_password_dialog_unittest.cc

Issue 8115020: add crypto module password dialog view and test. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix window's dependencies Created 9 years, 2 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
Index: chrome/browser/ui/crypto_module_password_dialog_unittest.cc
diff --git a/chrome/browser/ui/crypto_module_password_dialog_unittest.cc b/chrome/browser/ui/crypto_module_password_dialog_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de28410e48bb390643e3c5a3ca75d77d6cb71daf
--- /dev/null
+++ b/chrome/browser/ui/crypto_module_password_dialog_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2011 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 <string>
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/ui/crypto_module_password_dialog_view.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "views/controls/textfield/textfield.h"
+
+std::string kSlotName = "slot";
+std::string kServer = "server";
+
+namespace browser {
+CryptoModulePasswordReason kReason = kCryptoModulePasswordKeygen;
+
+class CryptoModulePasswordDialogViewTest : public testing::Test {
+ public:
+ CryptoModulePasswordDialogViewTest() : text_("") {}
Greg Spencer (Chromium) 2011/10/05 23:41:16 No need to initialize text_ with "": that's the de
alicet1 2011/10/06 22:04:08 Done.
+ ~CryptoModulePasswordDialogViewTest() {}
+ void Capture(const char* text) {
+ text_ = text;
+ }
+ void CreateDialog(const CryptoModulePasswordCallback& callback) {
+ dialog_.reset(new CryptoModulePasswordDialogView(
+ kSlotName, kReason, kServer, callback));
+ }
+ browser::CryptoModulePasswordCallback* callback_;
+ std::string text_;
+ scoped_ptr<CryptoModulePasswordDialogView> dialog_;
+};
+
+TEST_F(CryptoModulePasswordDialogViewTest, TestAccept) {
+ browser::CryptoModulePasswordCallback cb(
+ base::Bind(&browser::CryptoModulePasswordDialogViewTest::Capture,
+ base::Unretained(this)));
+ CreateDialog(cb);
+ EXPECT_EQ(dialog_->password_entry_, dialog_->GetInitiallyFocusedView());
+ EXPECT_TRUE(dialog_->IsModal());
+ std::string kPassword = "diAl0g";
Greg Spencer (Chromium) 2011/10/05 23:41:16 const std::string?
alicet1 2011/10/06 22:04:08 Done.
+ dialog_->password_entry_->SetText(UTF8ToUTF16(kPassword));
+ EXPECT_TRUE(dialog_->Accept());
+ EXPECT_EQ(kPassword, text_);
+ string16 empty;
Greg Spencer (Chromium) 2011/10/05 23:41:16 const string16?
alicet1 2011/10/06 22:04:08 Done.
+ EXPECT_EQ(empty, dialog_->password_entry_->text());
+}
+} // namespace browser

Powered by Google App Engine
This is Rietveld 408576698