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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
6 #include "components/content_settings/core/common/content_settings.h"
7 #include "components/content_settings/core/common/content_settings_types.h"
8 #include "testing/gtest/include/gtest/gtest.h"
15 TestCallback() : current_(-1) {}
17 PermissionMenuModel::ChangeCallback
callback() {
18 return base::Bind(&TestCallback::PermissionChanged
, base::Unretained(this));
20 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo
& permission
) {
21 current_
= permission
.setting
;
29 TEST(PermissionMenuModelTest
, TestDefault
) {
30 TestCallback callback
;
31 WebsiteSettingsUI::PermissionInfo permission
;
32 permission
.type
= CONTENT_SETTINGS_TYPE_COOKIES
;
33 permission
.setting
= CONTENT_SETTING_ALLOW
;
34 permission
.default_setting
= CONTENT_SETTING_ALLOW
;
35 PermissionMenuModel
model(
36 GURL("http://www.google.com"), permission
, callback
.callback());
37 EXPECT_EQ(3, model
.GetItemCount());
40 TEST(PermissionMenuModelTest
, TestDefaultMediaHttp
) {
41 TestCallback callback
;
42 WebsiteSettingsUI::PermissionInfo permission
;
43 permission
.type
= CONTENT_SETTINGS_TYPE_MEDIASTREAM
;
44 permission
.setting
= CONTENT_SETTING_ALLOW
;
45 permission
.default_setting
= CONTENT_SETTING_ALLOW
;
46 PermissionMenuModel
model(
47 GURL("http://www.google.com"), permission
, callback
.callback());
48 EXPECT_EQ(2, model
.GetItemCount());
51 TEST(PermissionMenuModelTest
, TestAllowBlock
) {
52 TestCallback callback
;
53 PermissionMenuModel
model(GURL("http://www.google.com"),
54 CONTENT_SETTING_ALLOW
,
56 EXPECT_EQ(2, model
.GetItemCount());