| 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 2958e7e44a8d6eb1a340348d0904301bdf22fe1c..38c301af48a2261082cc714289a22cbc814f2a5f 100644
|
| --- a/chrome/browser/chromeos/note_taking_helper_unittest.cc
|
| +++ b/chrome/browser/chromeos/note_taking_helper_unittest.cc
|
| @@ -192,6 +192,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)
|
| @@ -207,6 +213,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)
|
| @@ -346,6 +356,54 @@ 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 kEmptyArrayId =
|
| + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
| + const extensions::ExtensionId kEmptyId = "cccccccccccccccccccccccccccccccc";
|
| + const std::string kName = "Some App";
|
| +
|
| + // "action_handlers": ["new_note"]
|
| + auto has_new_note = CreateExtension(
|
| + kNewNoteId, kName,
|
| + extensions::ListBuilder()
|
| + .Append(app_runtime::ToString(app_runtime::ACTION_TYPE_NEW_NOTE))
|
| + .Build());
|
| + InstallExtension(has_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());
|
| +
|
| + // Only the "new_note" extension is returned from GetAvailableApps.
|
| + std::vector<NoteTakingAppInfo> apps = helper()->GetAvailableApps(profile());
|
| + ASSERT_EQ(1u, apps.size());
|
| + EXPECT_EQ(GetAppString(kNewNoteId, kName, false), GetAppString(apps[0]));
|
| +}
|
| +
|
| +TEST_F(NoteTakingHelperTest, WhitelistedAndCustomAppsShowOnlyOnce) {
|
| + Init(ENABLE_PALETTE);
|
| +
|
| + auto extension = CreateExtension(
|
| + NoteTakingHelper::kProdKeepExtensionId, "Keep",
|
| + extensions::ListBuilder()
|
| + .Append(app_runtime::ToString(app_runtime::ACTION_TYPE_NEW_NOTE))
|
| + .Build());
|
| + InstallExtension(extension.get(), profile());
|
| +
|
| + std::vector<NoteTakingAppInfo> apps = helper()->GetAvailableApps(profile());
|
| + ASSERT_EQ(1u, apps.size());
|
| + EXPECT_EQ(GetAppString(NoteTakingHelper::kProdKeepExtensionId, "Keep", false),
|
| + GetAppString(apps[0]));
|
| +}
|
| +
|
| TEST_F(NoteTakingHelperTest, LaunchChromeApp) {
|
| Init(ENABLE_PALETTE);
|
| auto extension =
|
|
|