| 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 "base/test/values_test_util.h" |
| 6 #include "extensions/common/manifest_constants.h" |
| 7 #include "extensions/common/manifest_handlers/action_handlers_handler.h" |
| 8 #include "extensions/common/manifest_test.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace extensions { |
| 12 |
| 13 namespace app_runtime = api::app_runtime; |
| 14 |
| 15 namespace { |
| 16 |
| 17 class ActionHandlersManifestTest : public ManifestTest { |
| 18 protected: |
| 19 ManifestData CreateManifest(const std::string& action_handlers) { |
| 20 std::unique_ptr<base::DictionaryValue> manifest = |
| 21 base::DictionaryValue::From( |
| 22 base::test::ParseJson("{ \n" |
| 23 " \"name\": \"test\", \n" |
| 24 " \"version\": \"1\", \n" |
| 25 " \"manifest_version\": 2, \n" |
| 26 " \"action_handlers\": " + |
| 27 action_handlers + "} \n")); |
| 28 EXPECT_TRUE(manifest); |
| 29 return ManifestData(std::move(manifest), "test"); |
| 30 } |
| 31 }; |
| 32 |
| 33 } // namespace |
| 34 |
| 35 TEST_F(ActionHandlersManifestTest, InvalidType) { |
| 36 LoadAndExpectError(CreateManifest("32"), |
| 37 manifest_errors::kInvalidActionHandlersType); |
| 38 LoadAndExpectError(CreateManifest("[true]"), |
| 39 manifest_errors::kInvalidActionHandlersType); |
| 40 LoadAndExpectError(CreateManifest("[\"invalid_handler\"]"), |
| 41 manifest_errors::kInvalidActionHandlersActionType); |
| 42 } |
| 43 |
| 44 TEST_F(ActionHandlersManifestTest, VerifyParse) { |
| 45 auto none = LoadAndExpectSuccess(CreateManifest("[]")); |
| 46 auto new_note = LoadAndExpectSuccess(CreateManifest("[\"new_note\"]")); |
| 47 |
| 48 EXPECT_EQ(std::set<app_runtime::ActionType>{}, |
| 49 ActionHandlersInfo::GetActionHandlers(none.get())); |
| 50 EXPECT_EQ( |
| 51 std::set<app_runtime::ActionType>{app_runtime::ACTION_TYPE_NEW_NOTE}, |
| 52 ActionHandlersInfo::GetActionHandlers(new_note.get())); |
| 53 } |
| 54 |
| 55 } // namespace extensions |
| OLD | NEW |