| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 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" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 class DevicePermissionsPromptTest : public testing::Test {}; | |
| 18 | |
| 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()) | |
| 27 .Build(); | |
| 28 | |
| 29 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt = | |
| 30 DevicePermissionsPrompt::CreateHidPromptForTest(extension.get(), false); | |
| 31 EXPECT_EQ(base::ASCIIToUTF16("Select a HID device"), prompt->GetHeading()); | |
| 32 EXPECT_EQ( | |
| 33 base::ASCIIToUTF16( | |
| 34 "The application \"Test Application\" is requesting access to one of " | |
| 35 "your devices."), | |
| 36 prompt->GetPromptMessage()); | |
| 37 | |
| 38 prompt = | |
| 39 DevicePermissionsPrompt::CreateHidPromptForTest(extension.get(), true); | |
| 40 EXPECT_EQ(base::ASCIIToUTF16("Select HID devices"), prompt->GetHeading()); | |
| 41 EXPECT_EQ( | |
| 42 base::ASCIIToUTF16( | |
| 43 "The application \"Test Application\" is requesting access to one or " | |
| 44 "more of your devices."), | |
| 45 prompt->GetPromptMessage()); | |
| 46 } | |
| 47 | |
| 48 TEST_F(DevicePermissionsPromptTest, UsbPromptMessages) { | |
| 49 scoped_refptr<Extension> extension = | |
| 50 ExtensionBuilder() | |
| 51 .SetManifest(DictionaryBuilder() | |
| 52 .Set("name", "Test Application") | |
| 53 .Set("manifest_version", 2) | |
| 54 .Set("version", "1.0") | |
| 55 .Build()) | |
| 56 .Build(); | |
| 57 | |
| 58 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt = | |
| 59 DevicePermissionsPrompt::CreateUsbPromptForTest(extension.get(), false); | |
| 60 EXPECT_EQ(base::ASCIIToUTF16("Select a USB device"), prompt->GetHeading()); | |
| 61 EXPECT_EQ( | |
| 62 base::ASCIIToUTF16( | |
| 63 "The application \"Test Application\" is requesting access to one of " | |
| 64 "your devices."), | |
| 65 prompt->GetPromptMessage()); | |
| 66 | |
| 67 prompt = | |
| 68 DevicePermissionsPrompt::CreateUsbPromptForTest(extension.get(), true); | |
| 69 EXPECT_EQ(base::ASCIIToUTF16("Select USB devices"), prompt->GetHeading()); | |
| 70 EXPECT_EQ( | |
| 71 base::ASCIIToUTF16( | |
| 72 "The application \"Test Application\" is requesting access to one or " | |
| 73 "more of your devices."), | |
| 74 prompt->GetPromptMessage()); | |
| 75 } | |
| 76 | |
| 77 } // namespace | |
| 78 | |
| 79 } // namespace extensions | |
| OLD | NEW |