Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / website_settings / permission_menu_model_unittest.cc
blob4ddf3ca5536cf688e4a8e6b5b4a6958eda8783b8
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 "chrome/grit/generated_resources.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/base/l10n/l10n_util.h"
10 namespace {
12 class TestCallback {
13 public:
14 TestCallback() : current_(-1) {}
16 PermissionMenuModel::ChangeCallback callback() {
17 return base::Bind(&TestCallback::PermissionChanged, base::Unretained(this));
19 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo& permission) {
20 current_ = permission.setting;
23 int current_;
26 } // namespace
28 TEST(PermissionMenuModelTest, TestDefault) {
29 TestCallback callback;
30 WebsiteSettingsUI::PermissionInfo permission;
31 permission.type = CONTENT_SETTINGS_TYPE_COOKIES;
32 permission.setting = CONTENT_SETTING_ALLOW;
33 permission.default_setting = CONTENT_SETTING_ALLOW;
34 PermissionMenuModel model(
35 GURL("http://www.google.com"), permission, callback.callback());
36 EXPECT_EQ(3, model.GetItemCount());
39 TEST(PermissionMenuModelTest, TestDefaultMediaHttp) {
40 TestCallback callback;
41 WebsiteSettingsUI::PermissionInfo permission;
42 permission.type = CONTENT_SETTINGS_TYPE_MEDIASTREAM;
43 permission.setting = CONTENT_SETTING_ALLOW;
44 permission.default_setting = CONTENT_SETTING_ALLOW;
45 PermissionMenuModel model(
46 GURL("http://www.google.com"), permission, callback.callback());
47 EXPECT_EQ(2, model.GetItemCount());
50 TEST(PermissionMenuModelTest, TestAllowBlock) {
51 TestCallback callback;
52 PermissionMenuModel model(GURL("http://www.google.com"),
53 CONTENT_SETTING_ALLOW,
54 callback.callback());
55 EXPECT_EQ(2, model.GetItemCount());
58 TEST(PermissionMenuModelTest, TestFullscreenMouseLockFileUrl) {
59 TestCallback callback;
60 WebsiteSettingsUI::PermissionInfo permission;
61 permission.type = CONTENT_SETTINGS_TYPE_FULLSCREEN;
62 permission.setting = CONTENT_SETTING_ASK;
63 permission.default_setting = CONTENT_SETTING_ASK;
64 PermissionMenuModel fullscreen_model(GURL("file:///test.html"), permission,
65 callback.callback());
66 EXPECT_EQ(1, fullscreen_model.GetItemCount());
67 EXPECT_EQ(
68 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK),
69 fullscreen_model.GetLabelAt(0));
71 permission.type = CONTENT_SETTINGS_TYPE_MOUSELOCK;
72 PermissionMenuModel mouselock_model(GURL("file:///test.html"), permission,
73 callback.callback());
74 EXPECT_EQ(1, mouselock_model.GetItemCount());
75 EXPECT_EQ(
76 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK),
77 fullscreen_model.GetLabelAt(0));