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

Side by Side Diff: chrome/browser/cocoa/page_info_window_mac_unittest.mm

Issue 3171031: Add mixed content warning to the Page Info bubble.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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/app/generated_resources.grd ('k') | chrome/browser/page_info_model.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "app/l10n_util.h" 5 #include "app/l10n_util.h"
6 #include "base/scoped_nsobject.h" 6 #include "base/scoped_nsobject.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #import "chrome/browser/cocoa/page_info_window_mac.h" 11 #import "chrome/browser/cocoa/page_info_window_mac.h"
12 #import "chrome/browser/cocoa/page_info_window_controller.h" 12 #import "chrome/browser/cocoa/page_info_window_controller.h"
13 #include "chrome/browser/cocoa/browser_test_helper.h" 13 #include "chrome/browser/cocoa/browser_test_helper.h"
14 #import "chrome/browser/cocoa/cocoa_test_helper.h" 14 #import "chrome/browser/cocoa/cocoa_test_helper.h"
15 #include "chrome/browser/page_info_model.h" 15 #include "chrome/browser/page_info_model.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 17
18 namespace { 18 namespace {
19 19
20 class FakeModel : public PageInfoModel { 20 class FakeModel : public PageInfoModel {
21 public: 21 public:
22 void AddSection(bool state, 22 void AddSection(SectionInfoState state,
23 const string16& title, 23 const string16& title,
24 const string16& description, 24 const string16& description,
25 SectionInfoType type) { 25 SectionInfoType type) {
26 sections_.push_back(SectionInfo( 26 sections_.push_back(SectionInfo(
27 state, 27 state,
28 title, 28 title,
29 string16(), 29 string16(),
30 description, 30 description,
31 type)); 31 type));
32 } 32 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 PageInfoWindowController* controller_; // Weak, owns self. 105 PageInfoWindowController* controller_; // Weak, owns self.
106 PageInfoWindowMac* bridge_; // Weak, owned by controller. 106 PageInfoWindowMac* bridge_; // Weak, owned by controller.
107 FakeModel* model_; // Weak, owned by bridge. 107 FakeModel* model_; // Weak, owned by bridge.
108 108
109 NSWindow* window_; // Weak, owned by controller. 109 NSWindow* window_; // Weak, owned by controller.
110 }; 110 };
111 111
112 112
113 TEST_F(PageInfoWindowMacTest, NoHistoryNoSecurity) { 113 TEST_F(PageInfoWindowMacTest, NoHistoryNoSecurity) {
114 model_->AddSection(false, 114 model_->AddSection(PageInfoModel::SECTION_STATE_ERROR,
115 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), 115 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE),
116 l10n_util::GetStringFUTF16( 116 l10n_util::GetStringFUTF16(
117 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY, 117 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY,
118 ASCIIToUTF16("google.com")), 118 ASCIIToUTF16("google.com")),
119 PageInfoModel::SECTION_INFO_IDENTITY); 119 PageInfoModel::SECTION_INFO_IDENTITY);
120 model_->AddSection(false, 120 model_->AddSection(PageInfoModel::SECTION_STATE_ERROR,
121 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), 121 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE),
122 l10n_util::GetStringFUTF16( 122 l10n_util::GetStringFUTF16(
123 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, 123 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
124 ASCIIToUTF16("google.com")), 124 ASCIIToUTF16("google.com")),
125 PageInfoModel::SECTION_INFO_CONNECTION); 125 PageInfoModel::SECTION_INFO_CONNECTION);
126 126
127 bridge_->ModelChanged(); 127 bridge_->ModelChanged();
128 128
129 CheckWindow(1, 2); 129 CheckWindow(1, 2);
130 } 130 }
131 131
132 132
133 TEST_F(PageInfoWindowMacTest, HistoryNoSecurity) { 133 TEST_F(PageInfoWindowMacTest, HistoryNoSecurity) {
134 model_->AddSection(false, 134 model_->AddSection(PageInfoModel::SECTION_STATE_ERROR,
135 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), 135 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE),
136 l10n_util::GetStringFUTF16( 136 l10n_util::GetStringFUTF16(
137 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY, 137 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY,
138 ASCIIToUTF16("google.com")), 138 ASCIIToUTF16("google.com")),
139 PageInfoModel::SECTION_INFO_IDENTITY); 139 PageInfoModel::SECTION_INFO_IDENTITY);
140 model_->AddSection(false, 140 model_->AddSection(PageInfoModel::SECTION_STATE_ERROR,
141 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), 141 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE),
142 l10n_util::GetStringFUTF16( 142 l10n_util::GetStringFUTF16(
143 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, 143 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
144 ASCIIToUTF16("google.com")), 144 ASCIIToUTF16("google.com")),
145 PageInfoModel::SECTION_INFO_CONNECTION); 145 PageInfoModel::SECTION_INFO_CONNECTION);
146 146
147 // In practice, the history information comes later because it's queried 147 // In practice, the history information comes later because it's queried
148 // asynchronously, so replicate the double-build here. 148 // asynchronously, so replicate the double-build here.
149 bridge_->ModelChanged(); 149 bridge_->ModelChanged();
150 150
151 model_->AddSection(false, 151 model_->AddSection(PageInfoModel::SECTION_STATE_ERROR,
152 l10n_util::GetStringUTF16( 152 l10n_util::GetStringUTF16(
153 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), 153 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
154 l10n_util::GetStringUTF16( 154 l10n_util::GetStringUTF16(
155 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY), 155 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY),
156 PageInfoModel::SECTION_INFO_FIRST_VISIT); 156 PageInfoModel::SECTION_INFO_FIRST_VISIT);
157 157
158 bridge_->ModelChanged(); 158 bridge_->ModelChanged();
159 159
160 CheckWindow(1, 3); 160 CheckWindow(1, 3);
161 } 161 }
162 162
163 163
164 TEST_F(PageInfoWindowMacTest, NoHistoryMixedSecurity) { 164 TEST_F(PageInfoWindowMacTest, NoHistoryMixedSecurity) {
165 model_->AddSection(true, 165 model_->AddSection(PageInfoModel::SECTION_STATE_OK,
166 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), 166 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE),
167 l10n_util::GetStringFUTF16( 167 l10n_util::GetStringFUTF16(
168 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, 168 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY,
169 ASCIIToUTF16("Goat Security Systems")), 169 ASCIIToUTF16("Goat Security Systems")),
170 PageInfoModel::SECTION_INFO_IDENTITY); 170 PageInfoModel::SECTION_INFO_IDENTITY);
171 171
172 // This string is super long and the text should overflow the default clip 172 // This string is super long and the text should overflow the default clip
173 // region (kImageSize). 173 // region (kImageSize).
174 string16 title = 174 string16 title =
175 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE); 175 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE);
176 model_->AddSection(true, 176 model_->AddSection(PageInfoModel::SECTION_STATE_OK,
177 title, 177 title,
178 l10n_util::GetStringFUTF16( 178 l10n_util::GetStringFUTF16(
179 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, 179 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
180 l10n_util::GetStringFUTF16( 180 l10n_util::GetStringFUTF16(
181 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, 181 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
182 ASCIIToUTF16("chrome.google.com"), 182 ASCIIToUTF16("chrome.google.com"),
183 base::IntToString16(1024)), 183 base::IntToString16(1024)),
184 l10n_util::GetStringUTF16( 184 l10n_util::GetStringUTF16(
185 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)), 185 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)),
186 PageInfoModel::SECTION_INFO_CONNECTION); 186 PageInfoModel::SECTION_INFO_CONNECTION);
(...skipping 10 matching lines...) Expand all
197 NSBox* box = static_cast<NSBox*>(subview); 197 NSBox* box = static_cast<NSBox*>(subview);
198 if ([[box title] isEqualToString:targetTitle]) { 198 if ([[box title] isEqualToString:targetTitle]) {
199 // Typical box frame is ~55px, make sure this is extra large. 199 // Typical box frame is ~55px, make sure this is extra large.
200 EXPECT_LT(75, NSHeight([box frame])); 200 EXPECT_LT(75, NSHeight([box frame]));
201 } 201 }
202 } 202 }
203 } 203 }
204 } 204 }
205 205
206 } // namespace 206 } // namespace
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/page_info_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698