| Index: chrome/browser/chromeos/note_taking_helper_unittest.cc
|
| diff --git a/chrome/browser/chromeos/note_taking_helper_unittest.cc b/chrome/browser/chromeos/note_taking_helper_unittest.cc
|
| index 24e36c63dea7f3d93273043a25a32157f891fca1..e6818a9c440038c44c599446c9e41f32a0ea2812 100644
|
| --- a/chrome/browser/chromeos/note_taking_helper_unittest.cc
|
| +++ b/chrome/browser/chromeos/note_taking_helper_unittest.cc
|
| @@ -187,6 +187,12 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
|
| scoped_refptr<const extensions::Extension> CreateExtension(
|
| const extensions::ExtensionId& id,
|
| const std::string& name) {
|
| + return CreateExtension(id, name, nullptr);
|
| + }
|
| + scoped_refptr<const extensions::Extension> CreateExtension(
|
| + const extensions::ExtensionId& id,
|
| + const std::string& name,
|
| + std::unique_ptr<base::Value> action_handlers) {
|
| std::unique_ptr<base::DictionaryValue> manifest =
|
| extensions::DictionaryBuilder()
|
| .Set("name", name)
|
| @@ -202,6 +208,10 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
|
| .Build())
|
| .Build())
|
| .Build();
|
| +
|
| + if (action_handlers)
|
| + manifest->Set("action_handlers", std::move(action_handlers));
|
| +
|
| return extensions::ExtensionBuilder()
|
| .SetManifest(std::move(manifest))
|
| .SetID(id)
|
| @@ -341,6 +351,48 @@ TEST_F(NoteTakingHelperTest, ListChromeApps) {
|
| GetAppString(apps[1]));
|
| }
|
|
|
| +// Verify the note helper detects apps with "new_note" "action_handler" manifest
|
| +// entries.
|
| +TEST_F(NoteTakingHelperTest, CustomChromeApps) {
|
| + Init(ENABLE_PALETTE);
|
| +
|
| + const extensions::ExtensionId kNewNoteId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
| + const extensions::ExtensionId kInvalidNewNoteId =
|
| + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
| + const extensions::ExtensionId kEmptyArrayId =
|
| + "cccccccccccccccccccccccccccccccc";
|
| + const extensions::ExtensionId kEmptyId = "dddddddddddddddddddddddddddddddd";
|
| + const std::string kName = "Some App";
|
| +
|
| + // "action_handlers": ["new_note"]
|
| + auto has_new_note = CreateExtension(
|
| + kNewNoteId, kName, extensions::ListBuilder()
|
| + .Append(NoteTakingHelper::kChromeNewNoteAction)
|
| + .Build());
|
| + InstallExtension(has_new_note.get(), profile());
|
| + // "action_handlers": ["invalid", "new_note"]
|
| + auto invalid_new_note =
|
| + CreateExtension(kInvalidNewNoteId, kName,
|
| + extensions::ListBuilder()
|
| + .Append("invalid")
|
| + .Append(NoteTakingHelper::kChromeNewNoteAction)
|
| + .Build());
|
| + InstallExtension(invalid_new_note.get(), profile());
|
| + // "action_handlers": []
|
| + auto empty_array =
|
| + CreateExtension(kEmptyArrayId, kName, extensions::ListBuilder().Build());
|
| + InstallExtension(empty_array.get(), profile());
|
| + // (no action handler entry)
|
| + auto none = CreateExtension(kEmptyId, kName);
|
| + InstallExtension(none.get(), profile());
|
| +
|
| + std::vector<NoteTakingAppInfo> apps = helper()->GetAvailableApps(profile());
|
| + ASSERT_EQ(2u, apps.size());
|
| + EXPECT_EQ(GetAppString(kNewNoteId, kName, false), GetAppString(apps[0]));
|
| + EXPECT_EQ(GetAppString(kInvalidNewNoteId, kName, false),
|
| + GetAppString(apps[1]));
|
| +}
|
| +
|
| TEST_F(NoteTakingHelperTest, LaunchChromeApp) {
|
| Init(ENABLE_PALETTE);
|
| auto extension =
|
|
|