Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / browser / api / device_permissions_prompt_unittest.cc
blob2ab430d3a8607dd12fac036cb5733d3d6c1fe433
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
3 // found in the LICENSE file.
5 #include "base/memory/ref_counted.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "extensions/browser/api/device_permissions_prompt.h"
8 #include "extensions/common/extension.h"
9 #include "extensions/common/extension_builder.h"
10 #include "extensions/common/value_builder.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace extensions {
15 namespace {
17 class DevicePermissionsPromptTest : public testing::Test {};
19 TEST_F(DevicePermissionsPromptTest, HidPromptMessages) {
20 scoped_refptr<Extension> extension =
21 ExtensionBuilder()
22 .SetManifest(DictionaryBuilder()
23 .Set("name", "Test Application")
24 .Set("manifest_version", 2)
25 .Set("version", "1.0"))
26 .Build();
28 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt =
29 DevicePermissionsPrompt::CreateHidPromptForTest(extension.get(), false);
30 EXPECT_EQ(base::ASCIIToUTF16("Select a HID device"), prompt->GetHeading());
31 EXPECT_EQ(
32 base::ASCIIToUTF16(
33 "The application \"Test Application\" is requesting access to one of "
34 "your devices."),
35 prompt->GetPromptMessage());
37 prompt =
38 DevicePermissionsPrompt::CreateHidPromptForTest(extension.get(), true);
39 EXPECT_EQ(base::ASCIIToUTF16("Select HID devices"), prompt->GetHeading());
40 EXPECT_EQ(
41 base::ASCIIToUTF16(
42 "The application \"Test Application\" is requesting access to one or "
43 "more of your devices."),
44 prompt->GetPromptMessage());
47 TEST_F(DevicePermissionsPromptTest, UsbPromptMessages) {
48 scoped_refptr<Extension> extension =
49 ExtensionBuilder()
50 .SetManifest(DictionaryBuilder()
51 .Set("name", "Test Application")
52 .Set("manifest_version", 2)
53 .Set("version", "1.0"))
54 .Build();
56 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt =
57 DevicePermissionsPrompt::CreateUsbPromptForTest(extension.get(), false);
58 EXPECT_EQ(base::ASCIIToUTF16("Select a USB device"), prompt->GetHeading());
59 EXPECT_EQ(
60 base::ASCIIToUTF16(
61 "The application \"Test Application\" is requesting access to one of "
62 "your devices."),
63 prompt->GetPromptMessage());
65 prompt =
66 DevicePermissionsPrompt::CreateUsbPromptForTest(extension.get(), true);
67 EXPECT_EQ(base::ASCIIToUTF16("Select USB devices"), prompt->GetHeading());
68 EXPECT_EQ(
69 base::ASCIIToUTF16(
70 "The application \"Test Application\" is requesting access to one or "
71 "more of your devices."),
72 prompt->GetPromptMessage());
75 } // namespace
77 } // namespace extensions