1// Copyright (c) 2012 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.
4
5#include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
6#include "extensions/common/extension.h"
7#include "extensions/common/manifest_constants.h"
8#include "extensions/common/manifest_handlers/kiosk_mode_info.h"
9#include "testing/gtest/include/gtest/gtest.h"
10
11namespace extensions {
12
13class ExtensionManifestKioskModeTest : public ChromeManifestTest {
14};
15
16TEST_F(ExtensionManifestKioskModeTest, InvalidKioskEnabled) {
17  LoadAndExpectError("kiosk_enabled_invalid.json",
18                     manifest_errors::kInvalidKioskEnabled);
19}
20
21TEST_F(ExtensionManifestKioskModeTest, KioskEnabledHostedApp) {
22  scoped_refptr<Extension> extension(
23      LoadAndExpectSuccess("kiosk_enabled_hosted_app.json"));
24  EXPECT_FALSE(KioskModeInfo::IsKioskEnabled(extension.get()));
25}
26
27TEST_F(ExtensionManifestKioskModeTest, KioskEnabledPackagedApp) {
28  scoped_refptr<Extension> extension(
29      LoadAndExpectSuccess("kiosk_enabled_packaged_app.json"));
30  EXPECT_FALSE(KioskModeInfo::IsKioskEnabled(extension.get()));
31}
32
33TEST_F(ExtensionManifestKioskModeTest, KioskEnabledExtension) {
34  scoped_refptr<Extension> extension(
35      LoadAndExpectSuccess("kiosk_enabled_extension.json"));
36  EXPECT_FALSE(KioskModeInfo::IsKioskEnabled(extension.get()));
37}
38
39TEST_F(ExtensionManifestKioskModeTest, KioskEnabledPlatformApp) {
40  scoped_refptr<Extension> extension(
41      LoadAndExpectSuccess("kiosk_enabled_platform_app.json"));
42  EXPECT_TRUE(KioskModeInfo::IsKioskEnabled(extension.get()));
43}
44
45TEST_F(ExtensionManifestKioskModeTest, KioskDisabledPlatformApp) {
46  scoped_refptr<Extension> extension(
47      LoadAndExpectSuccess("kiosk_disabled_platform_app.json"));
48  EXPECT_FALSE(KioskModeInfo::IsKioskEnabled(extension.get()));
49}
50
51TEST_F(ExtensionManifestKioskModeTest, KioskDefaultPlatformApp) {
52  scoped_refptr<Extension> extension(
53      LoadAndExpectSuccess("kiosk_default_platform_app.json"));
54  EXPECT_FALSE(KioskModeInfo::IsKioskEnabled(extension.get()));
55  EXPECT_FALSE(KioskModeInfo::IsKioskOnly(extension.get()));
56}
57
58TEST_F(ExtensionManifestKioskModeTest, KioskEnabledDefaultRequired) {
59  scoped_refptr<Extension> extension(
60      LoadAndExpectSuccess("kiosk_enabled_platform_app.json"));
61  EXPECT_TRUE(KioskModeInfo::IsKioskEnabled(extension.get()));
62  EXPECT_FALSE(KioskModeInfo::IsKioskOnly(extension.get()));
63}
64
65TEST_F(ExtensionManifestKioskModeTest, KioskOnlyPlatformApp) {
66  scoped_refptr<Extension> extension(
67      LoadAndExpectSuccess("kiosk_only_platform_app.json"));
68  EXPECT_TRUE(KioskModeInfo::IsKioskOnly(extension.get()));
69}
70
71TEST_F(ExtensionManifestKioskModeTest, KioskOnlyInvalid) {
72  LoadAndExpectError("kiosk_only_invalid.json",
73                     manifest_errors::kInvalidKioskOnly);
74}
75
76TEST_F(ExtensionManifestKioskModeTest, KioskOnlyButNotEnabled) {
77  LoadAndExpectError("kiosk_only_not_enabled.json",
78                     manifest_errors::kInvalidKioskOnlyButNotEnabled);
79}
80
81TEST_F(ExtensionManifestKioskModeTest, KioskOnlyHostedApp) {
82  scoped_refptr<Extension> extension(
83      LoadAndExpectSuccess("kiosk_only_hosted_app.json"));
84  EXPECT_FALSE(KioskModeInfo::IsKioskOnly(extension.get()));
85}
86
87TEST_F(ExtensionManifestKioskModeTest, KioskOnlyPackagedApp) {
88  scoped_refptr<Extension> extension(
89      LoadAndExpectSuccess("kiosk_only_packaged_app.json"));
90  EXPECT_FALSE(KioskModeInfo::IsKioskOnly(extension.get()));
91}
92
93TEST_F(ExtensionManifestKioskModeTest, KioskOnlyExtension) {
94  scoped_refptr<Extension> extension(
95      LoadAndExpectSuccess("kiosk_only_extension.json"));
96  EXPECT_FALSE(KioskModeInfo::IsKioskOnly(extension.get()));
97}
98
99}  // namespace extensions
100