Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3078)

Unified Diff: extensions/renderer/argument_spec_builder.h

Issue 2847843002: [Extensions Bindings] Move signature parsing tests to their own file (Closed)
Patch Set: jbroman's Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/api_signature_unittest.cc ('k') | extensions/renderer/argument_spec_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/argument_spec_builder.h
diff --git a/extensions/renderer/argument_spec_builder.h b/extensions/renderer/argument_spec_builder.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f0b8760c60c1c8c8f73ded46f02db3eebb4cc94
--- /dev/null
+++ b/extensions/renderer/argument_spec_builder.h
@@ -0,0 +1,50 @@
+// 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.
+
+#ifndef EXTENSIONS_RENDERER_ARGUMENT_SPEC_BUILDER_H_
+#define EXTENSIONS_RENDERER_ARGUMENT_SPEC_BUILDER_H_
+
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/strings/string_piece.h"
+#include "extensions/renderer/argument_spec.h"
+
+namespace extensions {
+
+// A utility class for helping construct ArgumentSpecs in tests.
+// NOTE: This is designed to be test-only. It's not worth adding to production
+// code because it's a) only a bit of syntactic sugar and b) rife with footguns.
+class ArgumentSpecBuilder {
+ public:
+ explicit ArgumentSpecBuilder(ArgumentType type);
+ ArgumentSpecBuilder(ArgumentType type, base::StringPiece name);
+
+ ~ArgumentSpecBuilder();
+
+ ArgumentSpecBuilder& MakeOptional();
+ ArgumentSpecBuilder& AddProperty(base::StringPiece property_name,
+ std::unique_ptr<ArgumentSpec> property_spec);
+ ArgumentSpecBuilder& SetMinimum(int minimum);
+ ArgumentSpecBuilder& SetListType(std::unique_ptr<ArgumentSpec> list_type);
+ ArgumentSpecBuilder& SetRef(base::StringPiece ref);
+ ArgumentSpecBuilder& SetChoices(
+ std::vector<std::unique_ptr<ArgumentSpec>> choices);
+ ArgumentSpecBuilder& SetEnums(std::set<std::string> enum_values);
+ ArgumentSpecBuilder& SetAdditionalProperties(
+ std::unique_ptr<ArgumentSpec> additional_properties);
+ std::unique_ptr<ArgumentSpec> Build();
+
+ private:
+ std::unique_ptr<ArgumentSpec> spec_;
+ ArgumentSpec::PropertiesMap properties_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArgumentSpecBuilder);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_ARGUMENT_SPEC_BUILDER_H_
« no previous file with comments | « extensions/renderer/api_signature_unittest.cc ('k') | extensions/renderer/argument_spec_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698