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

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: 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 const char kSlotName[] = "slot";
Peter Kasting 2012/04/16 22:31:13 Nit: These can just go in CreateCryptoDialog()
15 std::string kServer = "server"; 16 const char kServer[] = "server";
16 17
17 namespace browser { 18 namespace browser {
18 CryptoModulePasswordReason kReason = kCryptoModulePasswordKeygen;
19 19
20 class CryptoModulePasswordDialogViewTest : public testing::Test { 20 class CryptoModulePasswordDialogViewTest : public testing::Test {
21 public: 21 public:
22 CryptoModulePasswordDialogViewTest() {} 22 CryptoModulePasswordDialogViewTest() {}
23 ~CryptoModulePasswordDialogViewTest() {} 23 ~CryptoModulePasswordDialogViewTest() {}
24
24 void Capture(const char* text) { 25 void Capture(const char* text) {
25 text_ = text; 26 text_ = text;
26 } 27 }
27 void CreateDialogCrypto(const CryptoModulePasswordCallback& callback) { 28
28 dialog_.reset(new CryptoModulePasswordDialogView( 29 void CreateCryptoDialog(const CryptoModulePasswordCallback& callback) {
29 kSlotName, kReason, kServer, callback)); 30 dialog_.reset(new CryptoModulePasswordDialogView(kSlotName,
31 kCryptoModulePasswordKeygen, kServer, callback));
30 } 32 }
31 browser::CryptoModulePasswordCallback* callback_; 33
34 CryptoModulePasswordCallback* callback_;
32 std::string text_; 35 std::string text_;
33 scoped_ptr<CryptoModulePasswordDialogView> dialog_; 36 scoped_ptr<CryptoModulePasswordDialogView> dialog_;
34 }; 37 };
35 38
36 TEST_F(CryptoModulePasswordDialogViewTest, TestAccept) { 39 TEST_F(CryptoModulePasswordDialogViewTest, TestAccept) {
37 browser::CryptoModulePasswordCallback cb( 40 CryptoModulePasswordCallback cb(
38 base::Bind(&browser::CryptoModulePasswordDialogViewTest::Capture, 41 base::Bind(&CryptoModulePasswordDialogViewTest::Capture,
39 base::Unretained(this))); 42 base::Unretained(this)));
40 CreateDialogCrypto(cb); 43 CreateCryptoDialog(cb);
41 EXPECT_EQ(dialog_->password_entry_, dialog_->GetInitiallyFocusedView()); 44 EXPECT_EQ(dialog_->password_entry_, dialog_->GetInitiallyFocusedView());
42 EXPECT_TRUE(dialog_->GetModalType() != ui::MODAL_TYPE_NONE); 45 EXPECT_TRUE(dialog_->GetModalType() != ui::MODAL_TYPE_NONE);
43 const std::string kPassword = "diAl0g"; 46 const std::string kPassword = "diAl0g";
44 dialog_->password_entry_->SetText(UTF8ToUTF16(kPassword)); 47 dialog_->password_entry_->SetText(ASCIIToUTF16(kPassword));
45 EXPECT_TRUE(dialog_->Accept()); 48 EXPECT_TRUE(dialog_->Accept());
46 EXPECT_EQ(kPassword, text_); 49 EXPECT_EQ(kPassword, text_);
47 const string16 empty; 50 const string16 empty;
48 EXPECT_EQ(empty, dialog_->password_entry_->text()); 51 EXPECT_EQ(empty, dialog_->password_entry_->text());
49 } 52 }
53
50 } // namespace browser 54 } // 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