OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ui/views/page_info/page_info_bubble_view.h" | 5 #include "chrome/browser/ui/views/page_info/page_info_bubble_view.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 9 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
10 #include "chrome/browser/ui/views/page_info/chosen_object_row.h" | 10 #include "chrome/browser/ui/views/page_info/chosen_object_row.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // PageInfoBubbleView::SetPermissionInfo(). | 179 // PageInfoBubbleView::SetPermissionInfo(). |
180 TEST_F(PageInfoBubbleViewTest, MAYBE_SetPermissionInfo) { | 180 TEST_F(PageInfoBubbleViewTest, MAYBE_SetPermissionInfo) { |
181 PermissionInfoList list(1); | 181 PermissionInfoList list(1); |
182 list.back().type = CONTENT_SETTINGS_TYPE_GEOLOCATION; | 182 list.back().type = CONTENT_SETTINGS_TYPE_GEOLOCATION; |
183 list.back().source = content_settings::SETTING_SOURCE_USER; | 183 list.back().source = content_settings::SETTING_SOURCE_USER; |
184 list.back().is_incognito = false; | 184 list.back().is_incognito = false; |
185 list.back().setting = CONTENT_SETTING_DEFAULT; | 185 list.back().setting = CONTENT_SETTING_DEFAULT; |
186 | 186 |
187 const int kExpectedChildren = | 187 const int kExpectedChildren = |
188 kViewsPerPermissionRow * | 188 kViewsPerPermissionRow * |
189 (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 11 : 13); | 189 (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 12 : 14); |
190 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); | 190 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); |
191 | 191 |
192 list.back().setting = CONTENT_SETTING_ALLOW; | 192 list.back().setting = CONTENT_SETTING_ALLOW; |
193 api_->SetPermissionInfo(list); | 193 api_->SetPermissionInfo(list); |
194 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); | 194 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); |
195 | 195 |
196 PermissionSelectorRow* selector = api_->GetPermissionSelectorAt(0); | 196 PermissionSelectorRow* selector = api_->GetPermissionSelectorAt(0); |
197 EXPECT_TRUE(selector); | 197 EXPECT_TRUE(selector); |
198 | 198 |
199 // Verify labels match the settings on the PermissionInfoList. | 199 // Verify labels match the settings on the PermissionInfoList. |
(...skipping 21 matching lines...) Expand all Loading... |
221 // However, since the setting is now default, recreating the dialog with those | 221 // However, since the setting is now default, recreating the dialog with those |
222 // settings should omit the permission from the UI. | 222 // settings should omit the permission from the UI. |
223 api_->SetPermissionInfo(list); | 223 api_->SetPermissionInfo(list); |
224 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); | 224 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); |
225 } | 225 } |
226 | 226 |
227 // Test UI construction and reconstruction with USB devices. | 227 // Test UI construction and reconstruction with USB devices. |
228 TEST_F(PageInfoBubbleViewTest, SetPermissionInfoWithUsbDevice) { | 228 TEST_F(PageInfoBubbleViewTest, SetPermissionInfoWithUsbDevice) { |
229 const int kExpectedChildren = | 229 const int kExpectedChildren = |
230 kViewsPerPermissionRow * | 230 kViewsPerPermissionRow * |
231 (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 11 : 13); | 231 (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 12 : 14); |
232 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); | 232 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); |
233 | 233 |
234 const GURL origin = GURL(kUrl).GetOrigin(); | 234 const GURL origin = GURL(kUrl).GetOrigin(); |
235 scoped_refptr<device::UsbDevice> device = | 235 scoped_refptr<device::UsbDevice> device = |
236 new device::MockUsbDevice(0, 0, "Google", "Gizmo", "1234567890"); | 236 new device::MockUsbDevice(0, 0, "Google", "Gizmo", "1234567890"); |
237 device_client_.usb_service()->AddDevice(device); | 237 device_client_.usb_service()->AddDevice(device); |
238 UsbChooserContext* store = | 238 UsbChooserContext* store = |
239 UsbChooserContextFactory::GetForProfile(web_contents_helper_.profile()); | 239 UsbChooserContextFactory::GetForProfile(web_contents_helper_.profile()); |
240 store->GrantDevicePermission(origin, origin, device->guid()); | 240 store->GrantDevicePermission(origin, origin, device->guid()); |
241 | 241 |
(...skipping 16 matching lines...) Expand all Loading... |
258 | 258 |
259 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 259 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
260 ui::EventTimeForNow(), 0, 0); | 260 ui::EventTimeForNow(), 0, 0); |
261 views::ButtonListener* button_listener = | 261 views::ButtonListener* button_listener = |
262 static_cast<views::ButtonListener*>(object_view); | 262 static_cast<views::ButtonListener*>(object_view); |
263 button_listener->ButtonPressed(button, event); | 263 button_listener->ButtonPressed(button, event); |
264 api_->SetPermissionInfo(list); | 264 api_->SetPermissionInfo(list); |
265 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); | 265 EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count()); |
266 EXPECT_FALSE(store->HasDevicePermission(origin, origin, device)); | 266 EXPECT_FALSE(store->HasDevicePermission(origin, origin, device)); |
267 } | 267 } |
OLD | NEW |