Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 "apps/launcher.h" | |
| 6 #include "base/memory/ptr_util.h" | |
| 7 #include "base/path_service.h" | |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | |
| 9 #include "chrome/common/chrome_paths.h" | |
| 10 #include "extensions/common/manifest_handlers/action_handlers_handler.h" | |
| 11 #include "extensions/test/extension_test_message_listener.h" | |
| 12 | |
| 13 namespace app_runtime = extensions::api::app_runtime; | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 class ActionHandlersBrowserTest : public ExtensionApiTest {}; | |
|
Devlin
2017/02/17 23:43:06
nit: prefer just "using ActionHandlersBrowserTest
jdufault
2017/02/21 21:07:40
Done.
| |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 IN_PROC_BROWSER_TEST_F(ActionHandlersBrowserTest, LaunchAppWithNewNote) { | |
| 22 // Load the app. Make sure to wait until it is done loading. | |
| 23 ExtensionTestMessageListener loader("loaded", false); | |
| 24 base::FilePath dir; | |
| 25 PathService::Get(chrome::DIR_TEST_DATA, &dir); | |
| 26 dir = dir.AppendASCII("extensions") | |
| 27 .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.
| |
| 28 .AppendASCII("action_handlers") | |
| 29 .AppendASCII("new_note"); | |
| 30 const extensions::Extension* app = LoadExtension(dir); | |
| 31 CHECK(app); | |
|
Devlin
2017/02/17 23:43:06
s/CHECK/ASSERT_TRUE
jdufault
2017/02/21 21:07:40
Done.
| |
| 32 EXPECT_TRUE(extensions::ActionHandlersInfo::HasActionHandler( | |
| 33 app, app_runtime::ACTION_TYPE_NEW_NOTE)); | |
| 34 loader.WaitUntilSatisfied(); | |
| 35 | |
| 36 // Fire a "new_note" action type, assert that app has received it. | |
| 37 ExtensionTestMessageListener new_note("hasNewNote = true", false); | |
| 38 auto action_data = base::MakeUnique<app_runtime::ActionData>(); | |
| 39 action_data->action_type = app_runtime::ActionType::ACTION_TYPE_NEW_NOTE; | |
| 40 apps::LaunchPlatformAppWithAction(profile(), app, std::move(action_data), | |
| 41 base::FilePath()); | |
| 42 new_note.WaitUntilSatisfied(); | |
| 43 } | |
| OLD | NEW |