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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_manage_view_controller_unittest.mm

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 4
5 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_manage_view_c ontroller.h" 5 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_manage_view_c ontroller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #import "chrome/browser/ui/cocoa/passwords/manage_password_item_view_controller. h" 10 #import "chrome/browser/ui/cocoa/passwords/manage_password_item_view_controller. h"
10 #include "chrome/browser/ui/cocoa/passwords/manage_passwords_controller_test.h" 11 #include "chrome/browser/ui/cocoa/passwords/manage_passwords_controller_test.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" 13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/gtest_mac.h" 15 #include "testing/gtest_mac.h"
15 16
16 @interface ManagePasswordsBubbleManageViewTestDelegate 17 @interface ManagePasswordsBubbleManageViewTestDelegate
17 : NSObject<ManagePasswordsBubbleContentViewDelegate> { 18 : NSObject<ManagePasswordsBubbleContentViewDelegate> {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 TEST_F(ManagePasswordsBubbleManageViewControllerTest, 80 TEST_F(ManagePasswordsBubbleManageViewControllerTest,
80 ShouldShowNoPasswordsWhenNoPasswordsExistForSite) { 81 ShouldShowNoPasswordsWhenNoPasswordsExistForSite) {
81 EXPECT_TRUE(model()->local_credentials().empty()); 82 EXPECT_TRUE(model()->local_credentials().empty());
82 EXPECT_EQ([NoPasswordsView class], [controller().contentView class]); 83 EXPECT_EQ([NoPasswordsView class], [controller().contentView class]);
83 } 84 }
84 85
85 TEST_F(ManagePasswordsBubbleManageViewControllerTest, 86 TEST_F(ManagePasswordsBubbleManageViewControllerTest,
86 ShouldShowAllPasswordItemsWhenPasswordsExistForSite) { 87 ShouldShowAllPasswordItemsWhenPasswordsExistForSite) {
87 // Add a few password entries. 88 // Add a few password entries.
88 autofill::PasswordFormMap map; 89 autofill::PasswordFormMap map;
89 autofill::PasswordForm form1; 90 scoped_ptr<autofill::PasswordForm> form1(new autofill::PasswordForm);
90 form1.username_value = base::ASCIIToUTF16("username1"); 91 form1->username_value = base::ASCIIToUTF16("username1");
91 form1.password_value = base::ASCIIToUTF16("password1"); 92 form1->password_value = base::ASCIIToUTF16("password1");
92 map[base::ASCIIToUTF16("username1")] = &form1; 93 map.insert(base::ASCIIToUTF16("username1"), form1.Pass());
93 94
94 autofill::PasswordForm form2; 95 scoped_ptr<autofill::PasswordForm> form2(new autofill::PasswordForm);
95 form2.username_value = base::ASCIIToUTF16("username2"); 96 form2->username_value = base::ASCIIToUTF16("username2");
96 form2.password_value = base::ASCIIToUTF16("password2"); 97 form2->password_value = base::ASCIIToUTF16("password2");
97 map[base::ASCIIToUTF16("username2")] = &form2; 98 map.insert(base::ASCIIToUTF16("username2"), form2.Pass());
98 99
99 // Add the entries to the model. 100 // Add the entries to the model.
100 ui_controller()->OnPasswordAutofilled(map); 101 ui_controller()->OnPasswordAutofilled(map);
101 model()->set_state(password_manager::ui::MANAGE_STATE); 102 model()->set_state(password_manager::ui::MANAGE_STATE);
102 103
103 // Check the view state. 104 // Check the view state.
104 EXPECT_FALSE(model()->local_credentials().empty()); 105 EXPECT_FALSE(model()->local_credentials().empty());
105 EXPECT_EQ([PasswordItemListView class], [controller().contentView class]); 106 EXPECT_EQ([PasswordItemListView class], [controller().contentView class]);
106 NSArray* items = base::mac::ObjCCastStrict<PasswordItemListView>( 107 NSArray* items = base::mac::ObjCCastStrict<PasswordItemListView>(
107 controller().contentView).itemViews; 108 controller().contentView).itemViews;
108 EXPECT_EQ(2U, [items count]); 109 EXPECT_EQ(2U, [items count]);
109 110
110 // Check the entry items. 111 // Check the entry items.
111 for (ManagePasswordItemViewController* item in items) { 112 for (ManagePasswordItemViewController* item in items) {
112 ManagePasswordItemManageView* itemContent = 113 ManagePasswordItemManageView* itemContent =
113 base::mac::ObjCCastStrict<ManagePasswordItemManageView>( 114 base::mac::ObjCCastStrict<ManagePasswordItemManageView>(
114 item.contentView); 115 item.contentView);
115 NSString* username = [itemContent.usernameField stringValue]; 116 NSString* username = [itemContent.usernameField stringValue];
116 if ([username isEqualToString:@"username1"]) { 117 if ([username isEqualToString:@"username1"]) {
117 EXPECT_NSEQ(@"password1", [itemContent.passwordField stringValue]); 118 EXPECT_NSEQ(@"password1", [itemContent.passwordField stringValue]);
118 } else if ([username isEqualToString:@"username2"]) { 119 } else if ([username isEqualToString:@"username2"]) {
119 EXPECT_NSEQ(@"password2", [itemContent.passwordField stringValue]); 120 EXPECT_NSEQ(@"password2", [itemContent.passwordField stringValue]);
120 } else { 121 } else {
121 NOTREACHED(); 122 NOTREACHED();
122 } 123 }
123 } 124 }
124 } 125 }
125 126
126 } // namespace 127 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698