Index: chrome/browser/chromeos/extensions/action_handlers/action_handlers_apitest.cc |
diff --git a/chrome/browser/chromeos/extensions/action_handlers/action_handlers_apitest.cc b/chrome/browser/chromeos/extensions/action_handlers/action_handlers_apitest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e2a2aed6808a57b08a2492f19c7be983a8bc39b7 |
--- /dev/null |
+++ b/chrome/browser/chromeos/extensions/action_handlers/action_handlers_apitest.cc |
@@ -0,0 +1,43 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "apps/launcher.h" |
+#include "base/memory/ptr_util.h" |
+#include "base/path_service.h" |
+#include "chrome/browser/extensions/extension_apitest.h" |
+#include "chrome/common/chrome_paths.h" |
+#include "extensions/common/manifest_handlers/action_handlers_handler.h" |
+#include "extensions/test/extension_test_message_listener.h" |
+ |
+namespace app_runtime = extensions::api::app_runtime; |
+ |
+namespace { |
+ |
+class ActionHandlersBrowserTest : public ExtensionApiTest {}; |
Devlin
2017/02/17 23:43:06
nit: prefer just "using ActionHandlersBrowserTest
jdufault
2017/02/21 21:07:40
Done.
|
+ |
+} // namespace |
+ |
+IN_PROC_BROWSER_TEST_F(ActionHandlersBrowserTest, LaunchAppWithNewNote) { |
+ // Load the app. Make sure to wait until it is done loading. |
+ ExtensionTestMessageListener loader("loaded", false); |
+ base::FilePath dir; |
+ PathService::Get(chrome::DIR_TEST_DATA, &dir); |
+ dir = dir.AppendASCII("extensions") |
+ .AppendASCII("api_test") |
Devlin
2017/02/17 23:43:06
test_data_dir_ should already point to chrome/test
jdufault
2017/02/21 21:07:40
Done.
|
+ .AppendASCII("action_handlers") |
+ .AppendASCII("new_note"); |
+ const extensions::Extension* app = LoadExtension(dir); |
+ CHECK(app); |
Devlin
2017/02/17 23:43:06
s/CHECK/ASSERT_TRUE
jdufault
2017/02/21 21:07:40
Done.
|
+ EXPECT_TRUE(extensions::ActionHandlersInfo::HasActionHandler( |
+ app, app_runtime::ACTION_TYPE_NEW_NOTE)); |
+ loader.WaitUntilSatisfied(); |
+ |
+ // Fire a "new_note" action type, assert that app has received it. |
+ ExtensionTestMessageListener new_note("hasNewNote = true", false); |
+ auto action_data = base::MakeUnique<app_runtime::ActionData>(); |
+ action_data->action_type = app_runtime::ActionType::ACTION_TYPE_NEW_NOTE; |
+ apps::LaunchPlatformAppWithAction(profile(), app, std::move(action_data), |
+ base::FilePath()); |
+ new_note.WaitUntilSatisfied(); |
+} |