Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 #include <string> | |
| 5 | |
| 6 #include "base/basictypes.h" | |
| 7 #include "base/bind.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "chrome/browser/ui/crypto_module_password_dialog_view.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 #include "views/controls/textfield/textfield.h" | |
| 12 | |
| 13 std::string kSlotName = "slot"; | |
| 14 std::string kServer = "server"; | |
| 15 | |
| 16 namespace browser { | |
| 17 CryptoModulePasswordReason kReason = kCryptoModulePasswordKeygen; | |
| 18 | |
| 19 class CryptoModulePasswordDialogViewTest : public testing::Test { | |
| 20 public: | |
| 21 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.
| |
| 22 ~CryptoModulePasswordDialogViewTest() {} | |
| 23 void Capture(const char* text) { | |
| 24 text_ = text; | |
| 25 } | |
| 26 void CreateDialog(const CryptoModulePasswordCallback& callback) { | |
| 27 dialog_.reset(new CryptoModulePasswordDialogView( | |
| 28 kSlotName, kReason, kServer, callback)); | |
| 29 } | |
| 30 browser::CryptoModulePasswordCallback* callback_; | |
| 31 std::string text_; | |
| 32 scoped_ptr<CryptoModulePasswordDialogView> dialog_; | |
| 33 }; | |
| 34 | |
| 35 TEST_F(CryptoModulePasswordDialogViewTest, TestAccept) { | |
| 36 browser::CryptoModulePasswordCallback cb( | |
| 37 base::Bind(&browser::CryptoModulePasswordDialogViewTest::Capture, | |
| 38 base::Unretained(this))); | |
| 39 CreateDialog(cb); | |
| 40 EXPECT_EQ(dialog_->password_entry_, dialog_->GetInitiallyFocusedView()); | |
| 41 EXPECT_TRUE(dialog_->IsModal()); | |
| 42 std::string kPassword = "diAl0g"; | |
|
Greg Spencer (Chromium)
2011/10/05 23:41:16
const std::string?
alicet1
2011/10/06 22:04:08
Done.
| |
| 43 dialog_->password_entry_->SetText(UTF8ToUTF16(kPassword)); | |
| 44 EXPECT_TRUE(dialog_->Accept()); | |
| 45 EXPECT_EQ(kPassword, text_); | |
| 46 string16 empty; | |
|
Greg Spencer (Chromium)
2011/10/05 23:41:16
const string16?
alicet1
2011/10/06 22:04:08
Done.
| |
| 47 EXPECT_EQ(empty, dialog_->password_entry_->text()); | |
| 48 } | |
| 49 } // namespace browser | |
| OLD | NEW |