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

Side by Side Diff: chrome/browser/ui/views/crypto_module_password_dialog_view_unittest.cc

Issue 9956157: views: Make everything in crypto module password dialog private except the ctor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: peter view Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/crypto_module_password_dialog_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/crypto_module_password_dialog_view.h"
6
4 #include <string> 7 #include <string>
5 8
6 #include "base/basictypes.h"
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/crypto_module_password_dialog.h" 11 #include "chrome/browser/ui/crypto_module_password_dialog.h"
10 #include "chrome/browser/ui/views/crypto_module_password_dialog_view.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/views/controls/textfield/textfield.h" 13 #include "ui/views/controls/textfield/textfield.h"
13 14
14 std::string kSlotName = "slot";
15 std::string kServer = "server";
16
17 namespace browser { 15 namespace browser {
18 CryptoModulePasswordReason kReason = kCryptoModulePasswordKeygen;
19 16
20 class CryptoModulePasswordDialogViewTest : public testing::Test { 17 class CryptoModulePasswordDialogViewTest : public testing::Test {
21 public: 18 public:
22 CryptoModulePasswordDialogViewTest() {} 19 CryptoModulePasswordDialogViewTest() {}
23 ~CryptoModulePasswordDialogViewTest() {} 20 ~CryptoModulePasswordDialogViewTest() {}
21
24 void Capture(const char* text) { 22 void Capture(const char* text) {
25 text_ = text; 23 text_ = text;
26 } 24 }
27 void CreateDialogCrypto(const CryptoModulePasswordCallback& callback) { 25
28 dialog_.reset(new CryptoModulePasswordDialogView( 26 void CreateCryptoDialog(const CryptoModulePasswordCallback& callback) {
29 kSlotName, kReason, kServer, callback)); 27 dialog_.reset(new CryptoModulePasswordDialogView("slot",
28 kCryptoModulePasswordKeygen, "server", callback));
30 } 29 }
31 browser::CryptoModulePasswordCallback* callback_; 30
31 CryptoModulePasswordCallback* callback_;
32 std::string text_; 32 std::string text_;
33 scoped_ptr<CryptoModulePasswordDialogView> dialog_; 33 scoped_ptr<CryptoModulePasswordDialogView> dialog_;
34 }; 34 };
35 35
36 TEST_F(CryptoModulePasswordDialogViewTest, TestAccept) { 36 TEST_F(CryptoModulePasswordDialogViewTest, TestAccept) {
37 browser::CryptoModulePasswordCallback cb( 37 CryptoModulePasswordCallback cb(
38 base::Bind(&browser::CryptoModulePasswordDialogViewTest::Capture, 38 base::Bind(&CryptoModulePasswordDialogViewTest::Capture,
39 base::Unretained(this))); 39 base::Unretained(this)));
40 CreateDialogCrypto(cb); 40 CreateCryptoDialog(cb);
41 EXPECT_EQ(dialog_->password_entry_, dialog_->GetInitiallyFocusedView()); 41 EXPECT_EQ(dialog_->password_entry_, dialog_->GetInitiallyFocusedView());
42 EXPECT_TRUE(dialog_->GetModalType() != ui::MODAL_TYPE_NONE); 42 EXPECT_TRUE(dialog_->GetModalType() != ui::MODAL_TYPE_NONE);
43 const std::string kPassword = "diAl0g"; 43 const std::string kPassword = "diAl0g";
44 dialog_->password_entry_->SetText(UTF8ToUTF16(kPassword)); 44 dialog_->password_entry_->SetText(ASCIIToUTF16(kPassword));
45 EXPECT_TRUE(dialog_->Accept()); 45 EXPECT_TRUE(dialog_->Accept());
46 EXPECT_EQ(kPassword, text_); 46 EXPECT_EQ(kPassword, text_);
47 const string16 empty; 47 const string16 empty;
48 EXPECT_EQ(empty, dialog_->password_entry_->text()); 48 EXPECT_EQ(empty, dialog_->password_entry_->text());
49 } 49 }
50
50 } // namespace browser 51 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/crypto_module_password_dialog_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698