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

Side by Side Diff: chrome/browser/ui/cocoa/page_info/permission_selector_button_unittest.mm

Issue 2754383004: Rename WebsiteSettings code to PageInfo. (Closed)
Patch Set: Upload missing comment fix for WebSettingsUI -> PageInfoUI. Created 3 years, 9 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/page_info/permission_selector_button.h" 5 #import "chrome/browser/ui/cocoa/page_info/permission_selector_button.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" 8 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
9 #include "chrome/browser/ui/page_info/website_settings_ui.h" 9 #include "chrome/browser/ui/page_info/page_info_ui.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/test/test_browser_thread_bundle.h" 11 #include "content/public/test/test_browser_thread_bundle.h"
12 12
13 @interface PermissionSelectorButton (Testing) 13 @interface PermissionSelectorButton (Testing)
14 - (NSMenu*)permissionMenu; 14 - (NSMenu*)permissionMenu;
15 @end 15 @end
16 16
17 namespace { 17 namespace {
18 18
19 const ContentSettingsType kTestPermissionType = 19 const ContentSettingsType kTestPermissionType =
20 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; 20 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC;
21 21
22 class PermissionSelectorButtonTest : public CocoaTest { 22 class PermissionSelectorButtonTest : public CocoaTest {
23 public: 23 public:
24 PermissionSelectorButtonTest() { 24 PermissionSelectorButtonTest() {
25 got_callback_ = false; 25 got_callback_ = false;
26 WebsiteSettingsUI::PermissionInfo test_info; 26 PageInfoUI::PermissionInfo test_info;
27 test_info.type = kTestPermissionType; 27 test_info.type = kTestPermissionType;
28 test_info.setting = CONTENT_SETTING_BLOCK; 28 test_info.setting = CONTENT_SETTING_BLOCK;
29 test_info.source = content_settings::SETTING_SOURCE_USER; 29 test_info.source = content_settings::SETTING_SOURCE_USER;
30 test_info.is_incognito = false; 30 test_info.is_incognito = false;
31 GURL test_url("http://www.google.com"); 31 GURL test_url("http://www.google.com");
32 PermissionMenuModel::ChangeCallback callback = base::Bind( 32 PermissionMenuModel::ChangeCallback callback = base::Bind(
33 &PermissionSelectorButtonTest::Callback, base::Unretained(this)); 33 &PermissionSelectorButtonTest::Callback, base::Unretained(this));
34 view_.reset([[PermissionSelectorButton alloc] 34 view_.reset([[PermissionSelectorButton alloc]
35 initWithPermissionInfo:test_info 35 initWithPermissionInfo:test_info
36 forURL:test_url 36 forURL:test_url
37 withCallback:callback 37 withCallback:callback
38 profile:&profile_]); 38 profile:&profile_]);
39 [[test_window() contentView] addSubview:view_]; 39 [[test_window() contentView] addSubview:view_];
40 } 40 }
41 41
42 void Callback(const WebsiteSettingsUI::PermissionInfo& permission) { 42 void Callback(const PageInfoUI::PermissionInfo& permission) {
43 EXPECT_TRUE(permission.type == kTestPermissionType); 43 EXPECT_TRUE(permission.type == kTestPermissionType);
44 got_callback_ = true; 44 got_callback_ = true;
45 } 45 }
46 46
47 content::TestBrowserThreadBundle thread_bundle_; 47 content::TestBrowserThreadBundle thread_bundle_;
48 TestingProfile profile_; 48 TestingProfile profile_;
49 49
50 bool got_callback_; 50 bool got_callback_;
51 base::scoped_nsobject<PermissionSelectorButton> view_; 51 base::scoped_nsobject<PermissionSelectorButton> view_;
52 }; 52 };
53 53
54 TEST_VIEW(PermissionSelectorButtonTest, view_); 54 TEST_VIEW(PermissionSelectorButtonTest, view_);
55 55
56 TEST_F(PermissionSelectorButtonTest, Callback) { 56 TEST_F(PermissionSelectorButtonTest, Callback) {
57 NSMenu* menu = [view_ permissionMenu]; 57 NSMenu* menu = [view_ permissionMenu];
58 NSMenuItem* item = [menu itemAtIndex:0]; 58 NSMenuItem* item = [menu itemAtIndex:0];
59 [[item target] performSelector:[item action] withObject:item]; 59 [[item target] performSelector:[item action] withObject:item];
60 EXPECT_TRUE(got_callback_); 60 EXPECT_TRUE(got_callback_);
61 } 61 }
62 62
63 } // namespace 63 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698