| Index: extensions/common/manifest_handlers/action_handlers_handler_unittest.cc
|
| diff --git a/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc b/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..865adb1e258e292ec522baaba650ff5381dac925
|
| --- /dev/null
|
| +++ b/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc
|
| @@ -0,0 +1,55 @@
|
| +// 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 "base/test/values_test_util.h"
|
| +#include "extensions/common/manifest_constants.h"
|
| +#include "extensions/common/manifest_handlers/action_handlers_handler.h"
|
| +#include "extensions/common/manifest_test.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +namespace app_runtime = api::app_runtime;
|
| +
|
| +namespace {
|
| +
|
| +class ActionHandlersManifestTest : public ManifestTest {
|
| + protected:
|
| + ManifestData CreateManifest(const std::string& action_handlers) {
|
| + std::unique_ptr<base::DictionaryValue> manifest =
|
| + base::DictionaryValue::From(
|
| + base::test::ParseJson("{ \n"
|
| + " \"name\": \"test\", \n"
|
| + " \"version\": \"1\", \n"
|
| + " \"manifest_version\": 2, \n"
|
| + " \"action_handlers\": " +
|
| + action_handlers + "} \n"));
|
| + EXPECT_TRUE(manifest);
|
| + return ManifestData(std::move(manifest), "test");
|
| + }
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +TEST_F(ActionHandlersManifestTest, InvalidType) {
|
| + LoadAndExpectError(CreateManifest("32"),
|
| + manifest_errors::kInvalidActionHandlersType);
|
| + LoadAndExpectError(CreateManifest("[true]"),
|
| + manifest_errors::kInvalidActionHandlersType);
|
| + LoadAndExpectError(CreateManifest("[\"invalid_handler\"]"),
|
| + manifest_errors::kInvalidActionHandlersActionType);
|
| +}
|
| +
|
| +TEST_F(ActionHandlersManifestTest, VerifyParse) {
|
| + auto none = LoadAndExpectSuccess(CreateManifest("[]"));
|
| + auto new_note = LoadAndExpectSuccess(CreateManifest("[\"new_note\"]"));
|
| +
|
| + EXPECT_EQ(std::set<app_runtime::ActionType>{},
|
| + ActionHandlersInfo::GetActionHandlers(none.get()));
|
| + EXPECT_EQ(
|
| + std::set<app_runtime::ActionType>{app_runtime::ACTION_TYPE_NEW_NOTE},
|
| + ActionHandlersInfo::GetActionHandlers(new_note.get()));
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|