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

Side by Side Diff: chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: rebase + blink reformat Created 3 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
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/page_info/page_info_ui.cc ('k') | chrome/browser/ui/webui/options/content_settings_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698