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
{
17 class DevicePermissionsPromptTest
: public testing::Test
{};
19 TEST_F(DevicePermissionsPromptTest
, HidPromptMessages
) {
20 scoped_refptr
<Extension
> extension
=
22 .SetManifest(DictionaryBuilder()
23 .Set("name", "Test Application")
24 .Set("manifest_version", 2)
25 .Set("version", "1.0"))
28 scoped_refptr
<DevicePermissionsPrompt::Prompt
> prompt
=
29 DevicePermissionsPrompt::CreateHidPromptForTest(extension
.get(), false);
30 EXPECT_EQ(base::ASCIIToUTF16("Select a HID device"), prompt
->GetHeading());
33 "The application \"Test Application\" is requesting access to one of "
35 prompt
->GetPromptMessage());
38 DevicePermissionsPrompt::CreateHidPromptForTest(extension
.get(), true);
39 EXPECT_EQ(base::ASCIIToUTF16("Select HID devices"), prompt
->GetHeading());
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
=
50 .SetManifest(DictionaryBuilder()
51 .Set("name", "Test Application")
52 .Set("manifest_version", 2)
53 .Set("version", "1.0"))
56 scoped_refptr
<DevicePermissionsPrompt::Prompt
> prompt
=
57 DevicePermissionsPrompt::CreateUsbPromptForTest(extension
.get(), false);
58 EXPECT_EQ(base::ASCIIToUTF16("Select a USB device"), prompt
->GetHeading());
61 "The application \"Test Application\" is requesting access to one of "
63 prompt
->GetPromptMessage());
66 DevicePermissionsPrompt::CreateUsbPromptForTest(extension
.get(), true);
67 EXPECT_EQ(base::ASCIIToUTF16("Select USB devices"), prompt
->GetHeading());
70 "The application \"Test Application\" is requesting access to one or "
71 "more of your devices."),
72 prompt
->GetPromptMessage());
77 } // namespace extensions