Chromium Code Reviews| 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..e59194d9ba859ebdbff7a4344587c24445bc5ccc 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,40 @@ 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 = |
|
Daniel Erat
2017/01/12 23:55:03
i think you aren't using this. did you mean to cre
jdufault
2017/01/14 00:30:42
Artifact from a previous patch before extension pa
|
| + "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(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])); |
|
Daniel Erat
2017/01/12 23:55:03
consider adding a test to check that whitelisted a
jdufault
2017/01/14 00:30:42
Done.
|
| +} |
| + |
| TEST_F(NoteTakingHelperTest, LaunchChromeApp) { |
| Init(ENABLE_PALETTE); |
| auto extension = |