buffet: Wrap buffet unit tests into buffet namespace
Just to make referencing shorter by removing buffet:: prefix.
BUG=None
TEST=FEATURE=test emerge-gizmo buffet
Change-Id: Ie2cb5645911481c2eb92f80f4847b0faaaea532d
Reviewed-on: https://chromium-review.googlesource.com/268787
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_definition_unittest.cc b/buffet/commands/command_definition_unittest.cc
index 171164d..e422324 100644
--- a/buffet/commands/command_definition_unittest.cc
+++ b/buffet/commands/command_definition_unittest.cc
@@ -6,8 +6,7 @@
#include <gtest/gtest.h>
-using buffet::ObjectSchema;
-using buffet::CommandDefinition;
+namespace buffet {
TEST(CommandVisibility, DefaultConstructor) {
CommandDefinition::Visibility visibility;
@@ -91,3 +90,5 @@
def.SetVisibility(CommandDefinition::Visibility::GetLocal());
EXPECT_EQ("local", def.GetVisibility().ToString());
}
+
+} // namespace buffet
diff --git a/buffet/commands/command_dictionary_unittest.cc b/buffet/commands/command_dictionary_unittest.cc
index 914bdd3..6a2c8d7 100644
--- a/buffet/commands/command_dictionary_unittest.cc
+++ b/buffet/commands/command_dictionary_unittest.cc
@@ -8,10 +8,12 @@
#include "buffet/commands/unittest_utils.h"
-using buffet::unittests::CreateDictionaryValue;
+namespace buffet {
+
+using unittests::CreateDictionaryValue;
TEST(CommandDictionary, Empty) {
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
EXPECT_TRUE(dict.IsEmpty());
EXPECT_EQ(nullptr, dict.FindCommand("robot.jump"));
EXPECT_TRUE(dict.GetCommandNamesByCategory("robotd").empty());
@@ -32,7 +34,7 @@
}
}
})");
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
EXPECT_TRUE(dict.LoadCommands(*json, "robotd", nullptr, nullptr));
EXPECT_EQ(1, dict.GetSize());
EXPECT_NE(nullptr, dict.FindCommand("robot.jump"));
@@ -56,7 +58,7 @@
}
TEST(CommandDictionary, LoadCommands_Failures) {
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
chromeos::ErrorPtr error;
// Command definition is not an object.
@@ -93,7 +95,7 @@
TEST(CommandDictionaryDeathTest, LoadCommands_RedefineInDifferentCategory) {
// Redefine commands in different category.
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
chromeos::ErrorPtr error;
auto json = CreateDictionaryValue("{'robot':{'jump':{}}}");
dict.LoadCommands(*json, "category1", nullptr, &error);
@@ -104,8 +106,8 @@
TEST(CommandDictionary, LoadCommands_CustomCommandNaming) {
// Custom command must start with '_'.
- buffet::CommandDictionary base_dict;
- buffet::CommandDictionary dict;
+ CommandDictionary base_dict;
+ CommandDictionary dict;
chromeos::ErrorPtr error;
auto json = CreateDictionaryValue(R"({
'base': {
@@ -133,8 +135,8 @@
TEST(CommandDictionary, LoadCommands_RedefineStdCommand) {
// Redefine commands parameter type.
- buffet::CommandDictionary base_dict;
- buffet::CommandDictionary dict;
+ CommandDictionary base_dict;
+ CommandDictionary dict;
chromeos::ErrorPtr error;
auto json = CreateDictionaryValue(R"({
'base': {
@@ -201,10 +203,10 @@
}
}
})");
- buffet::CommandDictionary base_dict;
+ CommandDictionary base_dict;
base_dict.LoadCommands(*json_base, "base", nullptr, nullptr);
- auto json = buffet::unittests::CreateDictionaryValue(R"({
+ auto json = unittests::CreateDictionaryValue(R"({
'base': {
'reboot': {
'parameters': {'delay': {'minimum': 10}},
@@ -218,28 +220,29 @@
}
}
})");
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
dict.LoadCommands(*json, "device", &base_dict, nullptr);
- using buffet::CommandDefinition;
json = dict.GetCommandsAsJson(
[](const CommandDefinition* def) { return true; }, false, nullptr);
EXPECT_NE(nullptr, json.get());
- EXPECT_EQ("{'base':{'reboot':{'parameters':{'delay':{'minimum':10}}}},"
- "'robot':{'_jump':{'parameters':{'_height':'integer'}}}}",
- buffet::unittests::ValueToString(json.get()));
+ EXPECT_EQ(
+ "{'base':{'reboot':{'parameters':{'delay':{'minimum':10}}}},"
+ "'robot':{'_jump':{'parameters':{'_height':'integer'}}}}",
+ unittests::ValueToString(json.get()));
json = dict.GetCommandsAsJson(
[](const CommandDefinition* def) { return true; }, true, nullptr);
EXPECT_NE(nullptr, json.get());
- EXPECT_EQ("{'base':{'reboot':{'parameters':{'delay':{"
- "'maximum':100,'minimum':10,'type':'integer'}}}},"
- "'robot':{'_jump':{'parameters':{'_height':{'type':'integer'}}}}}",
- buffet::unittests::ValueToString(json.get()));
+ EXPECT_EQ(
+ "{'base':{'reboot':{'parameters':{'delay':{"
+ "'maximum':100,'minimum':10,'type':'integer'}}}},"
+ "'robot':{'_jump':{'parameters':{'_height':{'type':'integer'}}}}}",
+ unittests::ValueToString(json.get()));
}
TEST(CommandDictionary, GetCommandsAsJsonWithVisibility) {
- auto json = buffet::unittests::CreateDictionaryValue(R"({
+ auto json = unittests::CreateDictionaryValue(R"({
'test': {
'command1': {
'parameters': {},
@@ -283,63 +286,66 @@
}
}
})");
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
ASSERT_TRUE(dict.LoadCommands(*json, "test", nullptr, nullptr));
- using buffet::CommandDefinition;
json = dict.GetCommandsAsJson(
[](const CommandDefinition* def) { return true; }, false, nullptr);
ASSERT_NE(nullptr, json.get());
- EXPECT_EQ("{'test':{"
- "'command1':{'parameters':{}},"
- "'command2':{'parameters':{}},"
- "'command3':{'parameters':{}},"
- "'command4':{'parameters':{}},"
- "'command5':{'parameters':{}},"
- "'command6':{'parameters':{}},"
- "'command7':{'parameters':{}},"
- "'command8':{'parameters':{}}"
- "}}",
- buffet::unittests::ValueToString(json.get()));
+ EXPECT_EQ(
+ "{'test':{"
+ "'command1':{'parameters':{}},"
+ "'command2':{'parameters':{}},"
+ "'command3':{'parameters':{}},"
+ "'command4':{'parameters':{}},"
+ "'command5':{'parameters':{}},"
+ "'command6':{'parameters':{}},"
+ "'command7':{'parameters':{}},"
+ "'command8':{'parameters':{}}"
+ "}}",
+ unittests::ValueToString(json.get()));
json = dict.GetCommandsAsJson(
[](const CommandDefinition* def) { return def->GetVisibility().local; },
false, nullptr);
ASSERT_NE(nullptr, json.get());
- EXPECT_EQ("{'test':{"
- "'command2':{'parameters':{}},"
- "'command4':{'parameters':{}},"
- "'command6':{'parameters':{}},"
- "'command8':{'parameters':{}}"
- "}}",
- buffet::unittests::ValueToString(json.get()));
+ EXPECT_EQ(
+ "{'test':{"
+ "'command2':{'parameters':{}},"
+ "'command4':{'parameters':{}},"
+ "'command6':{'parameters':{}},"
+ "'command8':{'parameters':{}}"
+ "}}",
+ unittests::ValueToString(json.get()));
json = dict.GetCommandsAsJson(
[](const CommandDefinition* def) { return def->GetVisibility().cloud; },
false, nullptr);
ASSERT_NE(nullptr, json.get());
- EXPECT_EQ("{'test':{"
- "'command3':{'parameters':{}},"
- "'command4':{'parameters':{}},"
- "'command7':{'parameters':{}},"
- "'command8':{'parameters':{}}"
- "}}",
- buffet::unittests::ValueToString(json.get()));
+ EXPECT_EQ(
+ "{'test':{"
+ "'command3':{'parameters':{}},"
+ "'command4':{'parameters':{}},"
+ "'command7':{'parameters':{}},"
+ "'command8':{'parameters':{}}"
+ "}}",
+ unittests::ValueToString(json.get()));
json = dict.GetCommandsAsJson(
[](const CommandDefinition* def) {
return def->GetVisibility().local && def->GetVisibility().cloud;
}, false, nullptr);
ASSERT_NE(nullptr, json.get());
- EXPECT_EQ("{'test':{"
- "'command4':{'parameters':{}},"
- "'command8':{'parameters':{}}"
- "}}",
- buffet::unittests::ValueToString(json.get()));
+ EXPECT_EQ(
+ "{'test':{"
+ "'command4':{'parameters':{}},"
+ "'command8':{'parameters':{}}"
+ "}}",
+ unittests::ValueToString(json.get()));
}
TEST(CommandDictionary, LoadCommandsWithVisibility) {
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
auto json = CreateDictionaryValue(R"({
'base': {
'command1': {
@@ -392,7 +398,7 @@
}
TEST(CommandDictionary, LoadCommandsWithVisibility_Inheritance) {
- buffet::CommandDictionary base_dict;
+ CommandDictionary base_dict;
auto json = CreateDictionaryValue(R"({
'base': {
'command1': {
@@ -424,7 +430,7 @@
})");
EXPECT_TRUE(base_dict.LoadCommands(*json, "testd", nullptr, nullptr));
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
json = CreateDictionaryValue(R"({
'base': {
'command1': {
@@ -481,7 +487,7 @@
}
TEST(CommandDictionary, LoadCommandsWithVisibility_Failures) {
- buffet::CommandDictionary dict;
+ CommandDictionary dict;
chromeos::ErrorPtr error;
auto json = CreateDictionaryValue(R"({
@@ -501,3 +507,5 @@
error->GetInnerError()->GetMessage());
error.reset();
}
+
+} // namespace buffet
diff --git a/buffet/commands/command_manager_unittest.cc b/buffet/commands/command_manager_unittest.cc
index 57e0d06..5b45cee 100644
--- a/buffet/commands/command_manager_unittest.cc
+++ b/buffet/commands/command_manager_unittest.cc
@@ -12,7 +12,9 @@
#include "buffet/commands/unittest_utils.h"
-using buffet::unittests::CreateDictionaryValue;
+namespace buffet {
+
+using unittests::CreateDictionaryValue;
namespace {
@@ -69,18 +71,18 @@
} // namespace
TEST(CommandManager, Empty) {
- buffet::CommandManager manager;
+ CommandManager manager;
EXPECT_TRUE(manager.GetCommandDictionary().IsEmpty());
}
TEST(CommandManager, LoadBaseCommandsJSON) {
- buffet::CommandManager manager;
+ CommandManager manager;
auto json = CreateDictionaryValue(kTestBaseCommands);
EXPECT_TRUE(manager.LoadBaseCommands(*json, nullptr));
}
TEST(CommandManager, LoadBaseCommandsFile) {
- buffet::CommandManager manager;
+ CommandManager manager;
auto json = CreateDictionaryValue(kTestBaseCommands);
base::FilePath temp_file = SaveJsonToTempFile(*json);
EXPECT_TRUE(manager.LoadBaseCommands(temp_file, nullptr));
@@ -88,13 +90,13 @@
}
TEST(CommandManager, LoadCommandsJSON) {
- buffet::CommandManager manager;
+ CommandManager manager;
auto json = CreateDictionaryValue(kTestVendorCommands);
EXPECT_TRUE(manager.LoadCommands(*json, "category", nullptr));
}
TEST(CommandManager, LoadCommandsFile) {
- buffet::CommandManager manager;
+ CommandManager manager;
// Load some standard command definitions first.
auto json = CreateDictionaryValue(R"({
'base': {
@@ -133,7 +135,7 @@
}
TEST(CommandManager, ShouldLoadStandardAndTestDefinitions) {
- buffet::CommandManager manager;
+ CommandManager manager;
base::ScopedTempDir temp;
CHECK(temp.CreateUniqueTempDir());
base::FilePath base_path{temp.path().Append("base_defs")};
@@ -159,7 +161,7 @@
}
TEST(CommandManager, UpdateCommandVisibility) {
- buffet::CommandManager manager;
+ CommandManager manager;
int update_count = 0;
auto on_command_change = [&update_count]() { update_count++; };
auto token = manager.AddOnCommandDefChanged(base::Bind(on_command_change));
@@ -185,10 +187,9 @@
})");
ASSERT_TRUE(manager.LoadCommands(*json, "test", nullptr));
EXPECT_EQ(1, update_count);
- const buffet::CommandDictionary& dict = manager.GetCommandDictionary();
+ const CommandDictionary& dict = manager.GetCommandDictionary();
EXPECT_TRUE(manager.SetCommandVisibility(
- {"foo._baz"},
- buffet::CommandDefinition::Visibility::GetLocal(), nullptr));
+ {"foo._baz"}, CommandDefinition::Visibility::GetLocal(), nullptr));
EXPECT_EQ(2, update_count);
EXPECT_EQ("local", dict.FindCommand("foo._baz")->GetVisibility().ToString());
EXPECT_EQ("all", dict.FindCommand("foo._bar")->GetVisibility().ToString());
@@ -197,8 +198,8 @@
chromeos::ErrorPtr error;
ASSERT_FALSE(manager.SetCommandVisibility(
{"foo._baz", "foo._bar", "test.cmd"},
- buffet::CommandDefinition::Visibility::GetLocal(), &error));
- EXPECT_EQ(buffet::errors::commands::kInvalidCommandName, error->GetCode());
+ CommandDefinition::Visibility::GetLocal(), &error));
+ EXPECT_EQ(errors::commands::kInvalidCommandName, error->GetCode());
EXPECT_EQ("Command 'test.cmd' is unknown", error->GetMessage());
// The visibility state of commands shouldn't have changed.
EXPECT_EQ(2, update_count);
@@ -207,11 +208,12 @@
EXPECT_EQ("none", dict.FindCommand("bar._quux")->GetVisibility().ToString());
EXPECT_TRUE(manager.SetCommandVisibility(
- {"foo._baz", "bar._quux"},
- buffet::CommandDefinition::Visibility::GetCloud(), nullptr));
+ {"foo._baz", "bar._quux"}, CommandDefinition::Visibility::GetCloud(),
+ nullptr));
EXPECT_EQ(3, update_count);
EXPECT_EQ("cloud", dict.FindCommand("foo._baz")->GetVisibility().ToString());
EXPECT_EQ("all", dict.FindCommand("foo._bar")->GetVisibility().ToString());
EXPECT_EQ("cloud", dict.FindCommand("bar._quux")->GetVisibility().ToString());
}
+} // namespace buffet
diff --git a/buffet/commands/dbus_command_dispatcher_unittest.cc b/buffet/commands/dbus_command_dispatcher_unittest.cc
index 262b85d..2391bb1 100644
--- a/buffet/commands/dbus_command_dispatcher_unittest.cc
+++ b/buffet/commands/dbus_command_dispatcher_unittest.cc
@@ -19,15 +19,15 @@
#include "buffet/commands/unittest_utils.h"
#include "buffet/dbus_constants.h"
-using buffet::unittests::CreateDictionaryValue;
+namespace buffet {
+
using chromeos::dbus_utils::AsyncEventSequencer;
+using testing::_;
using testing::AnyNumber;
using testing::InSequence;
using testing::Invoke;
using testing::Return;
-using testing::_;
-
-namespace buffet {
+using unittests::CreateDictionaryValue;
namespace {
const char kCommandCategory[] = "test_category";
diff --git a/buffet/commands/dbus_command_proxy_unittest.cc b/buffet/commands/dbus_command_proxy_unittest.cc
index c2ca7d8..1f94ca7 100644
--- a/buffet/commands/dbus_command_proxy_unittest.cc
+++ b/buffet/commands/dbus_command_proxy_unittest.cc
@@ -19,16 +19,16 @@
#include "buffet/commands/unittest_utils.h"
#include "buffet/dbus_constants.h"
+namespace buffet {
+
using ::testing::AnyNumber;
-using ::testing::Return;
using ::testing::Invoke;
+using ::testing::Return;
using ::testing::_;
-using buffet::unittests::CreateDictionaryValue;
-using chromeos::dbus_utils::AsyncEventSequencer;
using chromeos::VariantDictionary;
-
-namespace buffet {
+using chromeos::dbus_utils::AsyncEventSequencer;
+using unittests::CreateDictionaryValue;
namespace {
diff --git a/buffet/commands/object_schema_unittest.cc b/buffet/commands/object_schema_unittest.cc
index 850f64e..06d2ca7 100644
--- a/buffet/commands/object_schema_unittest.cc
+++ b/buffet/commands/object_schema_unittest.cc
@@ -19,14 +19,16 @@
#include "buffet/commands/schema_constants.h"
#include "buffet/commands/unittest_utils.h"
-using buffet::unittests::CreateValue;
-using buffet::unittests::CreateDictionaryValue;
-using buffet::unittests::ValueToString;
+namespace buffet {
+
+using unittests::CreateValue;
+using unittests::CreateDictionaryValue;
+using unittests::ValueToString;
namespace {
-template<typename T>
-std::vector<T> GetArrayValues(const buffet::native_types::Array& arr) {
+template <typename T>
+std::vector<T> GetArrayValues(const native_types::Array& arr) {
std::vector<T> values;
values.reserve(arr.size());
for (const auto& prop_value : arr) {
@@ -35,10 +37,10 @@
return values;
}
-template<typename T>
-std::vector<T> GetOneOfValues(const buffet::PropType* prop_type) {
- auto one_of = static_cast<const buffet::ConstraintOneOf*>(
- prop_type->GetConstraint(buffet::ConstraintType::OneOf));
+template <typename T>
+std::vector<T> GetOneOfValues(const PropType* prop_type) {
+ auto one_of = static_cast<const ConstraintOneOf*>(
+ prop_type->GetConstraint(ConstraintType::OneOf));
if (!one_of)
return {};
@@ -48,7 +50,7 @@
} // anonymous namespace
TEST(CommandSchema, IntPropType_Empty) {
- buffet::IntPropType prop;
+ IntPropType prop;
EXPECT_TRUE(prop.GetConstraints().empty());
EXPECT_FALSE(prop.HasOverriddenAttributes());
EXPECT_FALSE(prop.IsBasedOnSchema());
@@ -56,7 +58,7 @@
}
TEST(CommandSchema, IntPropType_Types) {
- buffet::IntPropType prop;
+ IntPropType prop;
EXPECT_EQ(nullptr, prop.GetBoolean());
EXPECT_EQ(&prop, prop.GetInt());
EXPECT_EQ(nullptr, prop.GetDouble());
@@ -66,11 +68,11 @@
}
TEST(CommandSchema, IntPropType_ToJson) {
- buffet::IntPropType prop;
+ IntPropType prop;
EXPECT_EQ("'integer'", ValueToString(prop.ToJson(false, nullptr).get()));
EXPECT_EQ("{'type':'integer'}",
ValueToString(prop.ToJson(true, nullptr).get()));
- buffet::IntPropType param2;
+ IntPropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_EQ("{}", ValueToString(param2.ToJson(false, nullptr).get()));
param2.FromJson(CreateDictionaryValue("{'minimum':3}").get(),
@@ -96,9 +98,9 @@
}
TEST(CommandSchema, IntPropType_FromJson) {
- buffet::IntPropType prop;
+ IntPropType prop;
prop.AddMinMaxConstraint(2, 8);
- buffet::IntPropType param2;
+ IntPropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_FALSE(param2.HasOverriddenAttributes());
EXPECT_TRUE(param2.IsBasedOnSchema());
@@ -126,7 +128,7 @@
}
TEST(CommandSchema, IntPropType_Validate) {
- buffet::IntPropType prop;
+ IntPropType prop;
prop.AddMinMaxConstraint(2, 4);
chromeos::ErrorPtr error;
EXPECT_FALSE(prop.ValidateValue(CreateValue("-1").get(), &error));
@@ -158,7 +160,7 @@
}
TEST(CommandSchema, IntPropType_CreateValue) {
- buffet::IntPropType prop;
+ IntPropType prop;
chromeos::ErrorPtr error;
auto val = prop.CreateValue(2, &error);
ASSERT_NE(nullptr, val.get());
@@ -168,13 +170,13 @@
val = prop.CreateValue("blah", &error);
EXPECT_EQ(nullptr, val.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
}
///////////////////////////////////////////////////////////////////////////////
TEST(CommandSchema, BoolPropType_Empty) {
- buffet::BooleanPropType prop;
+ BooleanPropType prop;
EXPECT_TRUE(prop.GetConstraints().empty());
EXPECT_FALSE(prop.HasOverriddenAttributes());
EXPECT_FALSE(prop.IsBasedOnSchema());
@@ -182,7 +184,7 @@
}
TEST(CommandSchema, BoolPropType_Types) {
- buffet::BooleanPropType prop;
+ BooleanPropType prop;
EXPECT_EQ(nullptr, prop.GetInt());
EXPECT_EQ(&prop, prop.GetBoolean());
EXPECT_EQ(nullptr, prop.GetDouble());
@@ -192,11 +194,11 @@
}
TEST(CommandSchema, BoolPropType_ToJson) {
- buffet::BooleanPropType prop;
+ BooleanPropType prop;
EXPECT_EQ("'boolean'", ValueToString(prop.ToJson(false, nullptr).get()));
EXPECT_EQ("{'type':'boolean'}",
ValueToString(prop.ToJson(true, nullptr).get()));
- buffet::BooleanPropType param2;
+ BooleanPropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_EQ("{}", ValueToString(param2.ToJson(false, nullptr).get()));
param2.FromJson(CreateDictionaryValue("{'enum':[true,false]}").get(), &prop,
@@ -211,17 +213,17 @@
}
TEST(CommandSchema, BoolPropType_FromJson) {
- buffet::BooleanPropType prop;
+ BooleanPropType prop;
prop.FromJson(CreateDictionaryValue("{'enum':[true]}").get(), &prop,
nullptr);
- buffet::BooleanPropType param2;
+ BooleanPropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_FALSE(param2.HasOverriddenAttributes());
EXPECT_TRUE(param2.IsBasedOnSchema());
EXPECT_EQ(std::vector<bool>{true}, GetOneOfValues<bool>(&prop));
- buffet::BooleanPropType prop_base;
- buffet::BooleanPropType param3;
+ BooleanPropType prop_base;
+ BooleanPropType param3;
ASSERT_TRUE(param3.FromJson(CreateDictionaryValue("{'default':false}").get(),
&prop_base, nullptr));
EXPECT_TRUE(param3.HasOverriddenAttributes());
@@ -230,7 +232,7 @@
}
TEST(CommandSchema, BoolPropType_Validate) {
- buffet::BooleanPropType prop;
+ BooleanPropType prop;
prop.FromJson(CreateDictionaryValue("{'enum':[true]}").get(), &prop,
nullptr);
chromeos::ErrorPtr error;
@@ -250,7 +252,7 @@
}
TEST(CommandSchema, BoolPropType_CreateValue) {
- buffet::BooleanPropType prop;
+ BooleanPropType prop;
chromeos::ErrorPtr error;
auto val = prop.CreateValue(true, &error);
ASSERT_NE(nullptr, val.get());
@@ -260,13 +262,13 @@
val = prop.CreateValue("blah", &error);
EXPECT_EQ(nullptr, val.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
}
///////////////////////////////////////////////////////////////////////////////
TEST(CommandSchema, DoublePropType_Empty) {
- buffet::DoublePropType prop;
+ DoublePropType prop;
EXPECT_DOUBLE_EQ(std::numeric_limits<double>::lowest(), prop.GetMinValue());
EXPECT_DOUBLE_EQ((std::numeric_limits<double>::max)(), prop.GetMaxValue());
EXPECT_FALSE(prop.HasOverriddenAttributes());
@@ -275,7 +277,7 @@
}
TEST(CommandSchema, DoublePropType_Types) {
- buffet::DoublePropType prop;
+ DoublePropType prop;
EXPECT_EQ(nullptr, prop.GetInt());
EXPECT_EQ(nullptr, prop.GetBoolean());
EXPECT_EQ(&prop, prop.GetDouble());
@@ -285,11 +287,11 @@
}
TEST(CommandSchema, DoublePropType_ToJson) {
- buffet::DoublePropType prop;
+ DoublePropType prop;
EXPECT_EQ("'number'", ValueToString(prop.ToJson(false, nullptr).get()));
EXPECT_EQ("{'type':'number'}",
ValueToString(prop.ToJson(true, nullptr).get()));
- buffet::DoublePropType param2;
+ DoublePropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_EQ("{}", ValueToString(param2.ToJson(false, nullptr).get()));
param2.FromJson(CreateDictionaryValue("{'minimum':3}").get(), &prop,
@@ -311,9 +313,9 @@
}
TEST(CommandSchema, DoublePropType_FromJson) {
- buffet::DoublePropType prop;
+ DoublePropType prop;
prop.AddMinMaxConstraint(2.5, 8.7);
- buffet::DoublePropType param2;
+ DoublePropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_FALSE(param2.HasOverriddenAttributes());
EXPECT_TRUE(param2.IsBasedOnSchema());
@@ -347,7 +349,7 @@
}
TEST(CommandSchema, DoublePropType_Validate) {
- buffet::DoublePropType prop;
+ DoublePropType prop;
prop.AddMinMaxConstraint(-1.2, 1.3);
chromeos::ErrorPtr error;
EXPECT_FALSE(prop.ValidateValue(CreateValue("-2").get(), &error));
@@ -373,7 +375,7 @@
}
TEST(CommandSchema, DoublePropType_CreateValue) {
- buffet::DoublePropType prop;
+ DoublePropType prop;
chromeos::ErrorPtr error;
auto val = prop.CreateValue(2.0, &error);
ASSERT_NE(nullptr, val.get());
@@ -383,13 +385,13 @@
val = prop.CreateValue("blah", &error);
EXPECT_EQ(nullptr, val.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
}
///////////////////////////////////////////////////////////////////////////////
TEST(CommandSchema, StringPropType_Empty) {
- buffet::StringPropType prop;
+ StringPropType prop;
EXPECT_EQ(0, prop.GetMinLength());
EXPECT_EQ((std::numeric_limits<int>::max)(), prop.GetMaxLength());
EXPECT_FALSE(prop.HasOverriddenAttributes());
@@ -398,7 +400,7 @@
}
TEST(CommandSchema, StringPropType_Types) {
- buffet::StringPropType prop;
+ StringPropType prop;
EXPECT_EQ(nullptr, prop.GetInt());
EXPECT_EQ(nullptr, prop.GetBoolean());
EXPECT_EQ(nullptr, prop.GetDouble());
@@ -408,11 +410,11 @@
}
TEST(CommandSchema, StringPropType_ToJson) {
- buffet::StringPropType prop;
+ StringPropType prop;
EXPECT_EQ("'string'", ValueToString(prop.ToJson(false, nullptr).get()));
EXPECT_EQ("{'type':'string'}",
ValueToString(prop.ToJson(true, nullptr).get()));
- buffet::StringPropType param2;
+ StringPropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_EQ("{}", ValueToString(param2.ToJson(false, nullptr).get()));
param2.FromJson(CreateDictionaryValue("{'minLength':3}").get(), &prop,
@@ -434,9 +436,9 @@
}
TEST(CommandSchema, StringPropType_FromJson) {
- buffet::StringPropType prop;
+ StringPropType prop;
prop.AddLengthConstraint(2, 8);
- buffet::StringPropType param2;
+ StringPropType param2;
param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_FALSE(param2.HasOverriddenAttributes());
EXPECT_TRUE(param2.IsBasedOnSchema());
@@ -470,7 +472,7 @@
}
TEST(CommandSchema, StringPropType_Validate) {
- buffet::StringPropType prop;
+ StringPropType prop;
prop.AddLengthConstraint(1, 3);
chromeos::ErrorPtr error;
EXPECT_FALSE(prop.ValidateValue(CreateValue("''").get(), &error));
@@ -502,7 +504,7 @@
}
TEST(CommandSchema, StringPropType_CreateValue) {
- buffet::StringPropType prop;
+ StringPropType prop;
chromeos::ErrorPtr error;
auto val = prop.CreateValue(std::string{"blah"}, &error);
ASSERT_NE(nullptr, val.get());
@@ -512,20 +514,20 @@
val = prop.CreateValue(4, &error);
EXPECT_EQ(nullptr, val.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
}
///////////////////////////////////////////////////////////////////////////////
TEST(CommandSchema, ObjectPropType_Empty) {
- buffet::ObjectPropType prop;
+ ObjectPropType prop;
EXPECT_TRUE(prop.HasOverriddenAttributes());
EXPECT_FALSE(prop.IsBasedOnSchema());
EXPECT_EQ(nullptr, prop.GetDefaultValue());
}
TEST(CommandSchema, ObjectPropType_Types) {
- buffet::ObjectPropType prop;
+ ObjectPropType prop;
EXPECT_EQ(nullptr, prop.GetInt());
EXPECT_EQ(nullptr, prop.GetBoolean());
EXPECT_EQ(nullptr, prop.GetDouble());
@@ -535,20 +537,20 @@
}
TEST(CommandSchema, ObjectPropType_ToJson) {
- buffet::ObjectPropType prop;
+ ObjectPropType prop;
EXPECT_EQ("{'additionalProperties':false,'properties':{}}",
ValueToString(prop.ToJson(false, nullptr).get()));
EXPECT_EQ("{'additionalProperties':false,'properties':{},'type':'object'}",
ValueToString(prop.ToJson(true, nullptr).get()));
EXPECT_FALSE(prop.IsBasedOnSchema());
- buffet::ObjectPropType prop2;
+ ObjectPropType prop2;
prop2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_EQ("{}", ValueToString(prop2.ToJson(false, nullptr).get()));
EXPECT_TRUE(prop2.IsBasedOnSchema());
- auto schema = buffet::ObjectSchema::Create();
- schema->AddProp("expires", buffet::PropType::Create(buffet::ValueType::Int));
- auto pw = buffet::PropType::Create(buffet::ValueType::String);
+ auto schema = ObjectSchema::Create();
+ schema->AddProp("expires", PropType::Create(ValueType::Int));
+ auto pw = PropType::Create(ValueType::String);
pw->GetString()->AddLengthConstraint(6, 100);
schema->AddProp("password", std::move(pw));
prop2.SetObjectSchema(std::move(schema));
@@ -561,7 +563,7 @@
"'type':'object'}",
ValueToString(prop2.ToJson(true, nullptr).get()));
- buffet::ObjectPropType prop3;
+ ObjectPropType prop3;
ASSERT_TRUE(prop3.FromJson(CreateDictionaryValue(
"{'default':{'expires':3,'password':'abracadabra'}}").get(), &prop2,
nullptr));
@@ -574,7 +576,7 @@
"'type':'object'}",
ValueToString(prop3.ToJson(true, nullptr).get()));
- buffet::ObjectPropType prop4;
+ ObjectPropType prop4;
ASSERT_TRUE(prop4.FromJson(CreateDictionaryValue(
"{'additionalProperties':true,"
"'default':{'expires':3,'password':'abracadabra'}}").get(), &prop2,
@@ -593,30 +595,30 @@
}
TEST(CommandSchema, ObjectPropType_FromJson) {
- buffet::ObjectPropType base_prop;
+ ObjectPropType base_prop;
EXPECT_TRUE(base_prop.FromJson(CreateDictionaryValue(
"{'properties':{'name':'string','age':'integer'}}").get(), nullptr,
nullptr));
auto schema = base_prop.GetObject()->GetObjectSchemaPtr();
- const buffet::PropType* prop = schema->GetProp("name");
- EXPECT_EQ(buffet::ValueType::String, prop->GetType());
+ const PropType* prop = schema->GetProp("name");
+ EXPECT_EQ(ValueType::String, prop->GetType());
prop = schema->GetProp("age");
- EXPECT_EQ(buffet::ValueType::Int, prop->GetType());
+ EXPECT_EQ(ValueType::Int, prop->GetType());
- buffet::ObjectPropType prop2;
+ ObjectPropType prop2;
ASSERT_TRUE(prop2.FromJson(CreateDictionaryValue(
"{'properties':{'name':'string','age':'integer'},"
"'default':{'name':'Bob','age':33}}").get(), nullptr, nullptr));
ASSERT_NE(nullptr, prop2.GetDefaultValue());
- const buffet::ObjectValue* defval = prop2.GetDefaultValue()->GetObject();
+ const ObjectValue* defval = prop2.GetDefaultValue()->GetObject();
ASSERT_NE(nullptr, defval);
- buffet::native_types::Object objval = defval->GetValue();
+ native_types::Object objval = defval->GetValue();
EXPECT_EQ("Bob", objval["name"]->GetString()->GetValue());
EXPECT_EQ(33, objval["age"]->GetInt()->GetValue());
}
TEST(CommandSchema, ObjectPropType_Validate) {
- buffet::ObjectPropType prop;
+ ObjectPropType prop;
prop.FromJson(CreateDictionaryValue(
"{'properties':{'expires':'integer',"
"'password':{'maxLength':100,'minLength':6}}}").get(), nullptr,
@@ -652,7 +654,7 @@
}
TEST(CommandSchema, ObjectPropType_Validate_Enum) {
- buffet::ObjectPropType prop;
+ ObjectPropType prop;
EXPECT_TRUE(prop.FromJson(CreateDictionaryValue(
"{'properties':{'width':'integer','height':'integer'},"
"'enum':[{'width':10,'height':20},{'width':100,'height':200}]}").get(),
@@ -673,45 +675,45 @@
}
TEST(CommandSchema, ObjectPropType_CreateValue) {
- buffet::ObjectPropType prop;
- buffet::IntPropType int_type;
+ ObjectPropType prop;
+ IntPropType int_type;
ASSERT_TRUE(prop.FromJson(CreateDictionaryValue(
"{'properties':{'width':'integer','height':'integer'},"
"'enum':[{'width':10,'height':20},{'width':100,'height':200}]}").get(),
nullptr, nullptr));
- buffet::native_types::Object obj{
- {"width", int_type.CreateValue(10, nullptr)},
- {"height", int_type.CreateValue(20, nullptr)},
+ native_types::Object obj{
+ {"width", int_type.CreateValue(10, nullptr)},
+ {"height", int_type.CreateValue(20, nullptr)},
};
chromeos::ErrorPtr error;
auto val = prop.CreateValue(obj, &error);
ASSERT_NE(nullptr, val.get());
EXPECT_EQ(nullptr, error.get());
- EXPECT_EQ(obj, val->GetValueAsAny().Get<buffet::native_types::Object>());
+ EXPECT_EQ(obj, val->GetValueAsAny().Get<native_types::Object>());
val = prop.CreateValue("blah", &error);
EXPECT_EQ(nullptr, val.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
}
///////////////////////////////////////////////////////////////////////////////
TEST(CommandSchema, ArrayPropType_Empty) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
EXPECT_FALSE(prop.HasOverriddenAttributes());
EXPECT_FALSE(prop.IsBasedOnSchema());
EXPECT_EQ(nullptr, prop.GetDefaultValue());
EXPECT_EQ(nullptr, prop.GetItemTypePtr());
- prop.SetItemType(buffet::PropType::Create(buffet::ValueType::Int));
+ prop.SetItemType(PropType::Create(ValueType::Int));
EXPECT_TRUE(prop.HasOverriddenAttributes());
EXPECT_FALSE(prop.IsBasedOnSchema());
EXPECT_NE(nullptr, prop.GetItemTypePtr());
}
TEST(CommandSchema, ArrayPropType_Types) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
EXPECT_EQ(nullptr, prop.GetInt());
EXPECT_EQ(nullptr, prop.GetBoolean());
EXPECT_EQ(nullptr, prop.GetDouble());
@@ -721,14 +723,14 @@
}
TEST(CommandSchema, ArrayPropType_ToJson) {
- buffet::ArrayPropType prop;
- prop.SetItemType(buffet::PropType::Create(buffet::ValueType::Int));
+ ArrayPropType prop;
+ prop.SetItemType(PropType::Create(ValueType::Int));
EXPECT_EQ("{'items':'integer'}",
ValueToString(prop.ToJson(false, nullptr).get()));
EXPECT_EQ("{'items':{'type':'integer'},'type':'array'}",
ValueToString(prop.ToJson(true, nullptr).get()));
EXPECT_FALSE(prop.IsBasedOnSchema());
- buffet::ArrayPropType prop2;
+ ArrayPropType prop2;
prop2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
EXPECT_EQ("{}", ValueToString(prop2.ToJson(false, nullptr).get()));
EXPECT_TRUE(prop2.IsBasedOnSchema());
@@ -741,24 +743,24 @@
}
TEST(CommandSchema, ArrayPropType_FromJson) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
EXPECT_TRUE(prop.FromJson(
CreateDictionaryValue("{'items':'integer'}").get(), nullptr, nullptr));
- EXPECT_EQ(buffet::ValueType::Int, prop.GetItemTypePtr()->GetType());
+ EXPECT_EQ(ValueType::Int, prop.GetItemTypePtr()->GetType());
- buffet::ArrayPropType prop2;
+ ArrayPropType prop2;
ASSERT_TRUE(prop2.FromJson(CreateDictionaryValue(
"{'items':'string','default':['foo', 'bar', 'baz']}").get(), nullptr,
nullptr));
ASSERT_NE(nullptr, prop2.GetDefaultValue());
- const buffet::ArrayValue* defval = prop2.GetDefaultValue()->GetArray();
+ const ArrayValue* defval = prop2.GetDefaultValue()->GetArray();
ASSERT_NE(nullptr, defval);
EXPECT_EQ((std::vector<std::string>{"foo", "bar", "baz"}),
GetArrayValues<std::string>(defval->GetValue()));
}
TEST(CommandSchema, ArrayPropType_Validate) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
prop.FromJson(CreateDictionaryValue(
"{'items':{'minimum':2.3, 'maximum':10.5}}").get(), nullptr,
nullptr);
@@ -781,7 +783,7 @@
}
TEST(CommandSchema, ArrayPropType_Validate_Enum) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
prop.FromJson(CreateDictionaryValue(
"{'items':'integer', 'enum':[[1], [2,3], [4,5,6]]}").get(), nullptr,
nullptr);
@@ -802,60 +804,64 @@
}
TEST(CommandSchema, ArrayPropType_CreateValue) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
ASSERT_TRUE(prop.FromJson(CreateDictionaryValue(
"{'items':{'properties':{'width':'integer','height':'integer'}}}").get(),
nullptr, nullptr));
chromeos::ErrorPtr error;
- buffet::native_types::Array arr;
+ native_types::Array arr;
auto val = prop.CreateValue(arr, &error);
ASSERT_NE(nullptr, val.get());
EXPECT_EQ(nullptr, error.get());
- EXPECT_EQ(arr, val->GetValueAsAny().Get<buffet::native_types::Array>());
+ EXPECT_EQ(arr, val->GetValueAsAny().Get<native_types::Array>());
EXPECT_EQ("[]", ValueToString(val->ToJson(nullptr).get()));
- buffet::IntPropType int_type;
- buffet::ObjectPropType obj_type;
+ IntPropType int_type;
+ ObjectPropType obj_type;
ASSERT_TRUE(obj_type.FromJson(CreateDictionaryValue(
"{'properties':{'width':'integer','height':'integer'}}").get(),
nullptr, nullptr));
- arr.push_back(obj_type.CreateValue(buffet::native_types::Object{
- {"width", int_type.CreateValue(10, nullptr)},
- {"height", int_type.CreateValue(20, nullptr)},
- }, nullptr));
- arr.push_back(obj_type.CreateValue(buffet::native_types::Object{
- {"width", int_type.CreateValue(17, nullptr)},
- {"height", int_type.CreateValue(18, nullptr)},
- }, nullptr));
+ arr.push_back(obj_type.CreateValue(
+ native_types::Object{
+ {"width", int_type.CreateValue(10, nullptr)},
+ {"height", int_type.CreateValue(20, nullptr)},
+ },
+ nullptr));
+ arr.push_back(obj_type.CreateValue(
+ native_types::Object{
+ {"width", int_type.CreateValue(17, nullptr)},
+ {"height", int_type.CreateValue(18, nullptr)},
+ },
+ nullptr));
val = prop.CreateValue(arr, &error);
ASSERT_NE(nullptr, val.get());
EXPECT_EQ(nullptr, error.get());
- EXPECT_EQ(arr, val->GetValueAsAny().Get<buffet::native_types::Array>());
+ EXPECT_EQ(arr, val->GetValueAsAny().Get<native_types::Array>());
EXPECT_EQ("[{'height':20,'width':10},{'height':18,'width':17}]",
ValueToString(val->ToJson(nullptr).get()));
val = prop.CreateValue("blah", &error);
EXPECT_EQ(nullptr, val.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
}
TEST(CommandSchema, ArrayPropType_NestedArrays_NotSupported) {
- buffet::ArrayPropType prop;
+ ArrayPropType prop;
chromeos::ErrorPtr error;
EXPECT_FALSE(prop.FromJson(CreateDictionaryValue(
"{'items':{'items':'integer'}}").get(), nullptr, &error));
- EXPECT_EQ(buffet::errors::commands::kInvalidObjectSchema, error->GetCode());
+ EXPECT_EQ(errors::commands::kInvalidObjectSchema, error->GetCode());
error.reset();
}
///////////////////////////////////////////////////////////////////////////////
TEST(CommandSchema, ObjectSchema_FromJson_Shorthand_TypeName) {
- buffet::ObjectSchema schema;
+ ObjectSchema schema;
const char* schema_str = "{"
"'param1':'integer',"
"'param2':'number',"
@@ -863,9 +869,9 @@
"}";
EXPECT_TRUE(schema.FromJson(CreateDictionaryValue(schema_str).get(), nullptr,
nullptr));
- EXPECT_EQ(buffet::ValueType::Int, schema.GetProp("param1")->GetType());
- EXPECT_EQ(buffet::ValueType::Double, schema.GetProp("param2")->GetType());
- EXPECT_EQ(buffet::ValueType::String, schema.GetProp("param3")->GetType());
+ EXPECT_EQ(ValueType::Int, schema.GetProp("param1")->GetType());
+ EXPECT_EQ(ValueType::Double, schema.GetProp("param2")->GetType());
+ EXPECT_EQ(ValueType::String, schema.GetProp("param3")->GetType());
EXPECT_EQ("integer", schema.GetProp("param1")->GetTypeAsString());
EXPECT_EQ("number", schema.GetProp("param2")->GetTypeAsString());
EXPECT_EQ("string", schema.GetProp("param3")->GetTypeAsString());
@@ -884,7 +890,7 @@
}
TEST(CommandSchema, ObjectSchema_FromJson_Full_TypeName) {
- buffet::ObjectSchema schema;
+ ObjectSchema schema;
const char* schema_str = "{"
"'param1':{'type':'integer'},"
"'param2':{'type':'number'},"
@@ -894,11 +900,11 @@
"}";
EXPECT_TRUE(schema.FromJson(CreateDictionaryValue(schema_str).get(), nullptr,
nullptr));
- EXPECT_EQ(buffet::ValueType::Int, schema.GetProp("param1")->GetType());
- EXPECT_EQ(buffet::ValueType::Double, schema.GetProp("param2")->GetType());
- EXPECT_EQ(buffet::ValueType::String, schema.GetProp("param3")->GetType());
- EXPECT_EQ(buffet::ValueType::Array, schema.GetProp("param4")->GetType());
- EXPECT_EQ(buffet::ValueType::Object, schema.GetProp("param5")->GetType());
+ EXPECT_EQ(ValueType::Int, schema.GetProp("param1")->GetType());
+ EXPECT_EQ(ValueType::Double, schema.GetProp("param2")->GetType());
+ EXPECT_EQ(ValueType::String, schema.GetProp("param3")->GetType());
+ EXPECT_EQ(ValueType::Array, schema.GetProp("param4")->GetType());
+ EXPECT_EQ(ValueType::Object, schema.GetProp("param5")->GetType());
EXPECT_EQ("integer", schema.GetProp("param1")->GetTypeAsString());
EXPECT_EQ("number", schema.GetProp("param2")->GetTypeAsString());
EXPECT_EQ("string", schema.GetProp("param3")->GetTypeAsString());
@@ -919,7 +925,7 @@
}
TEST(CommandSchema, ObjectSchema_FromJson_Shorthand_TypeDeduction_Scalar) {
- buffet::ObjectSchema schema;
+ ObjectSchema schema;
const char* schema_str = "{"
"'param1' :{'minimum':2},"
"'param2' :{'maximum':10},"
@@ -995,7 +1001,7 @@
EXPECT_EQ(10, schema.GetProp("param10")->GetString()->GetMaxLength());
EXPECT_EQ(3, schema.GetProp("param11")->GetString()->GetMinLength());
EXPECT_EQ(8, schema.GetProp("param11")->GetString()->GetMaxLength());
- const buffet::PropValue* val = schema.GetProp("param12")->GetDefaultValue();
+ const PropValue* val = schema.GetProp("param12")->GetDefaultValue();
EXPECT_EQ(12, val->GetInt()->GetValue());
val = schema.GetProp("param13")->GetDefaultValue();
EXPECT_DOUBLE_EQ(13.5, val->GetDouble()->GetValue());
@@ -1013,7 +1019,7 @@
}
TEST(CommandSchema, ObjectSchema_FromJson_Shorthand_TypeDeduction_Array) {
- buffet::ObjectSchema schema;
+ ObjectSchema schema;
const char* schema_str = "{"
"'param1' :[0,1,2,3],"
"'param2' :[0.0,1.1,2.2],"
@@ -1104,7 +1110,7 @@
"'param21':{'default':49},"
"'param22':'integer'"
"}";
- buffet::ObjectSchema base_schema;
+ ObjectSchema base_schema;
EXPECT_TRUE(base_schema.FromJson(CreateDictionaryValue(base_schema_str).get(),
nullptr, nullptr));
const char* schema_str = "{"
@@ -1131,7 +1137,7 @@
"'param21':{'default':8},"
"'param22':{'default':123}"
"}";
- buffet::ObjectSchema schema;
+ ObjectSchema schema;
EXPECT_TRUE(schema.FromJson(CreateDictionaryValue(schema_str).get(),
&base_schema, nullptr));
EXPECT_EQ(nullptr, schema.GetProp("param0"));
@@ -1202,7 +1208,7 @@
}
TEST(CommandSchema, ObjectSchema_UseDefaults) {
- buffet::ObjectPropType prop;
+ ObjectPropType prop;
const char* schema_str = "{'properties':{"
"'param1':{'default':true},"
"'param2':{'default':2},"
@@ -1218,15 +1224,15 @@
// Omit all.
auto value = prop.CreateValue();
ASSERT_TRUE(value->FromJson(CreateDictionaryValue("{}").get(), nullptr));
- buffet::native_types::Object obj = value->GetObject()->GetValue();
+ native_types::Object obj = value->GetObject()->GetValue();
EXPECT_TRUE(obj["param1"]->GetBoolean()->GetValue());
EXPECT_EQ(2, obj["param2"]->GetInt()->GetValue());
EXPECT_DOUBLE_EQ(3.3, obj["param3"]->GetDouble()->GetValue());
EXPECT_EQ("four", obj["param4"]->GetString()->GetValue());
- buffet::native_types::Object param5 = obj["param5"]->GetObject()->GetValue();
+ native_types::Object param5 = obj["param5"]->GetObject()->GetValue();
EXPECT_EQ(5, param5["x"]->GetInt()->GetValue());
EXPECT_EQ(6, param5["y"]->GetInt()->GetValue());
- buffet::native_types::Array param6 = obj["param6"]->GetArray()->GetValue();
+ native_types::Array param6 = obj["param6"]->GetArray()->GetValue();
EXPECT_EQ((std::vector<int>{1, 2, 3}), GetArrayValues<int>(param6));
// Specify some.
@@ -1272,7 +1278,7 @@
}
TEST(CommandSchema, ObjectSchema_FromJson_BaseSchema_Failures) {
- buffet::ObjectSchema schema;
+ ObjectSchema schema;
chromeos::ErrorPtr error;
const char* schema_str = "{"
"'param1':{}"
@@ -1386,3 +1392,5 @@
EXPECT_EQ("no_type_info", error->GetFirstError()->GetCode());
error.reset();
}
+
+} // namespace buffet
diff --git a/buffet/commands/schema_utils_unittest.cc b/buffet/commands/schema_utils_unittest.cc
index 8405722..9698317 100644
--- a/buffet/commands/schema_utils_unittest.cc
+++ b/buffet/commands/schema_utils_unittest.cc
@@ -18,172 +18,170 @@
#include "buffet/commands/schema_constants.h"
#include "buffet/commands/unittest_utils.h"
-using buffet::unittests::CreateDictionaryValue;
-using buffet::unittests::CreateValue;
-using buffet::unittests::ValueToString;
+namespace buffet {
+
+using unittests::CreateDictionaryValue;
+using unittests::CreateValue;
+using unittests::ValueToString;
using chromeos::VariantDictionary;
TEST(CommandSchemaUtils, TypedValueToJson_Scalar) {
- EXPECT_EQ("true",
- ValueToString(buffet::TypedValueToJson(true, nullptr).get()));
- EXPECT_EQ("false",
- ValueToString(buffet::TypedValueToJson(false, nullptr).get()));
+ EXPECT_EQ("true", ValueToString(TypedValueToJson(true, nullptr).get()));
+ EXPECT_EQ("false", ValueToString(TypedValueToJson(false, nullptr).get()));
- EXPECT_EQ("0", ValueToString(buffet::TypedValueToJson(0, nullptr).get()));
- EXPECT_EQ("-10", ValueToString(buffet::TypedValueToJson(-10, nullptr).get()));
- EXPECT_EQ("20", ValueToString(buffet::TypedValueToJson(20, nullptr).get()));
+ EXPECT_EQ("0", ValueToString(TypedValueToJson(0, nullptr).get()));
+ EXPECT_EQ("-10", ValueToString(TypedValueToJson(-10, nullptr).get()));
+ EXPECT_EQ("20", ValueToString(TypedValueToJson(20, nullptr).get()));
- EXPECT_EQ("0.0", ValueToString(buffet::TypedValueToJson(0.0, nullptr).get()));
- EXPECT_EQ("1.2", ValueToString(buffet::TypedValueToJson(1.2, nullptr).get()));
+ EXPECT_EQ("0.0", ValueToString(TypedValueToJson(0.0, nullptr).get()));
+ EXPECT_EQ("1.2", ValueToString(TypedValueToJson(1.2, nullptr).get()));
EXPECT_EQ("'abc'",
- ValueToString(buffet::TypedValueToJson(std::string("abc"),
- nullptr).get()));
+ ValueToString(TypedValueToJson(std::string("abc"), nullptr).get()));
std::vector<bool> bool_array{true, false};
EXPECT_EQ("[true,false]",
- ValueToString(buffet::TypedValueToJson(bool_array, nullptr).get()));
+ ValueToString(TypedValueToJson(bool_array, nullptr).get()));
std::vector<int> int_array{1, 2, 5};
EXPECT_EQ("[1,2,5]",
- ValueToString(buffet::TypedValueToJson(int_array, nullptr).get()));
+ ValueToString(TypedValueToJson(int_array, nullptr).get()));
std::vector<double> dbl_array{1.1, 2.2};
EXPECT_EQ("[1.1,2.2]",
- ValueToString(buffet::TypedValueToJson(dbl_array, nullptr).get()));
+ ValueToString(TypedValueToJson(dbl_array, nullptr).get()));
std::vector<std::string> str_array{"a", "bc"};
EXPECT_EQ("['a','bc']",
- ValueToString(buffet::TypedValueToJson(str_array, nullptr).get()));
+ ValueToString(TypedValueToJson(str_array, nullptr).get()));
}
TEST(CommandSchemaUtils, TypedValueToJson_Object) {
- buffet::IntPropType int_type;
- buffet::native_types::Object object;
+ IntPropType int_type;
+ native_types::Object object;
object.insert(std::make_pair("width", int_type.CreateValue(640, nullptr)));
object.insert(std::make_pair("height", int_type.CreateValue(480, nullptr)));
EXPECT_EQ("{'height':480,'width':640}",
- ValueToString(buffet::TypedValueToJson(object, nullptr).get()));
+ ValueToString(TypedValueToJson(object, nullptr).get()));
}
TEST(CommandSchemaUtils, TypedValueToJson_Array) {
- buffet::IntPropType int_type;
- buffet::native_types::Array arr;
+ IntPropType int_type;
+ native_types::Array arr;
arr.push_back(int_type.CreateValue(640, nullptr));
arr.push_back(int_type.CreateValue(480, nullptr));
- EXPECT_EQ("[640,480]",
- ValueToString(buffet::TypedValueToJson(arr, nullptr).get()));
+ EXPECT_EQ("[640,480]", ValueToString(TypedValueToJson(arr, nullptr).get()));
}
TEST(CommandSchemaUtils, TypedValueFromJson_Bool) {
bool value;
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("true").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("true").get(), nullptr, &value, nullptr));
EXPECT_TRUE(value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("false").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("false").get(), nullptr, &value, nullptr));
EXPECT_FALSE(value);
chromeos::ErrorPtr error;
- EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("0").get(), nullptr,
- &value, &error));
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_FALSE(
+ TypedValueFromJson(CreateValue("0").get(), nullptr, &value, &error));
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
error.reset();
}
TEST(CommandSchemaUtils, TypedValueFromJson_Int) {
int value;
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("0").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("0").get(), nullptr, &value, nullptr));
EXPECT_EQ(0, value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("23").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("23").get(), nullptr, &value, nullptr));
EXPECT_EQ(23, value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("-1234").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("-1234").get(), nullptr, &value, nullptr));
EXPECT_EQ(-1234, value);
chromeos::ErrorPtr error;
- EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
- &value, &error));
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_FALSE(
+ TypedValueFromJson(CreateValue("'abc'").get(), nullptr, &value, &error));
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
error.reset();
}
TEST(CommandSchemaUtils, TypedValueFromJson_Double) {
double value;
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("0").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("0").get(), nullptr, &value, nullptr));
EXPECT_DOUBLE_EQ(0.0, value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("0.0").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("0.0").get(), nullptr, &value, nullptr));
EXPECT_DOUBLE_EQ(0.0, value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("23").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("23").get(), nullptr, &value, nullptr));
EXPECT_EQ(23.0, value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("23.1").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("23.1").get(), nullptr, &value, nullptr));
EXPECT_EQ(23.1, value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("-1.23E+02").get(),
- nullptr, &value, nullptr));
+ EXPECT_TRUE(TypedValueFromJson(CreateValue("-1.23E+02").get(), nullptr,
+ &value, nullptr));
EXPECT_EQ(-123.0, value);
chromeos::ErrorPtr error;
- EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
- &value, &error));
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_FALSE(
+ TypedValueFromJson(CreateValue("'abc'").get(), nullptr, &value, &error));
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
error.reset();
}
TEST(CommandSchemaUtils, TypedValueFromJson_String) {
std::string value;
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("''").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("''").get(), nullptr, &value, nullptr));
EXPECT_EQ("", value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("'23'").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("'23'").get(), nullptr, &value, nullptr));
EXPECT_EQ("23", value);
- EXPECT_TRUE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
- &value, nullptr));
+ EXPECT_TRUE(
+ TypedValueFromJson(CreateValue("'abc'").get(), nullptr, &value, nullptr));
EXPECT_EQ("abc", value);
chromeos::ErrorPtr error;
- EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("12").get(), nullptr,
- &value, &error));
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_FALSE(
+ TypedValueFromJson(CreateValue("12").get(), nullptr, &value, &error));
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
error.reset();
}
TEST(CommandSchemaUtils, TypedValueFromJson_Object) {
- buffet::native_types::Object value;
- std::unique_ptr<buffet::ObjectSchema> schema{new buffet::ObjectSchema};
+ native_types::Object value;
+ std::unique_ptr<ObjectSchema> schema{new ObjectSchema};
- buffet::IntPropType age_prop;
+ IntPropType age_prop;
age_prop.AddMinMaxConstraint(0, 150);
schema->AddProp("age", age_prop.Clone());
- buffet::StringPropType name_prop;
+ StringPropType name_prop;
name_prop.AddLengthConstraint(1, 30);
schema->AddProp("name", name_prop.Clone());
- buffet::ObjectPropType type;
+ ObjectPropType type;
type.SetObjectSchema(std::move(schema));
- EXPECT_TRUE(buffet::TypedValueFromJson(
- CreateValue("{'age':20,'name':'Bob'}").get(), &type, &value, nullptr));
- buffet::native_types::Object value2;
+ EXPECT_TRUE(TypedValueFromJson(CreateValue("{'age':20,'name':'Bob'}").get(),
+ &type, &value, nullptr));
+ native_types::Object value2;
value2.insert(std::make_pair("age", age_prop.CreateValue(20, nullptr)));
value2.insert(std::make_pair("name",
name_prop.CreateValue(std::string("Bob"),
@@ -191,58 +189,58 @@
EXPECT_EQ(value2, value);
chromeos::ErrorPtr error;
- EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
- &value, &error));
- EXPECT_EQ(buffet::errors::commands::kTypeMismatch, error->GetCode());
+ EXPECT_FALSE(
+ TypedValueFromJson(CreateValue("'abc'").get(), nullptr, &value, &error));
+ EXPECT_EQ(errors::commands::kTypeMismatch, error->GetCode());
error.reset();
}
TEST(CommandSchemaUtils, TypedValueFromJson_Array) {
- buffet::native_types::Array arr;
- buffet::StringPropType str_type;
+ native_types::Array arr;
+ StringPropType str_type;
str_type.AddLengthConstraint(3, 100);
- buffet::ArrayPropType type;
+ ArrayPropType type;
type.SetItemType(str_type.Clone());
- EXPECT_TRUE(buffet::TypedValueFromJson(
- CreateValue("['foo', 'bar']").get(), &type, &arr, nullptr));
- buffet::native_types::Array arr2;
+ EXPECT_TRUE(TypedValueFromJson(CreateValue("['foo', 'bar']").get(), &type,
+ &arr, nullptr));
+ native_types::Array arr2;
arr2.push_back(str_type.CreateValue(std::string{"foo"}, nullptr));
arr2.push_back(str_type.CreateValue(std::string{"bar"}, nullptr));
EXPECT_EQ(arr2, arr);
chromeos::ErrorPtr error;
- EXPECT_FALSE(buffet::TypedValueFromJson(
- CreateValue("['baz', 'ab']").get(), &type, &arr, &error));
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_FALSE(TypedValueFromJson(CreateValue("['baz', 'ab']").get(), &type,
+ &arr, &error));
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
error.reset();
}
TEST(CommandSchemaUtils, PropValueToDBusVariant) {
- buffet::IntPropType int_type;
+ IntPropType int_type;
auto prop_value = int_type.CreateValue(5, nullptr);
EXPECT_EQ(5, PropValueToDBusVariant(prop_value.get()).Get<int>());
- buffet::BooleanPropType bool_type;
+ BooleanPropType bool_type;
prop_value = bool_type.CreateValue(true, nullptr);
EXPECT_TRUE(PropValueToDBusVariant(prop_value.get()).Get<bool>());
- buffet::DoublePropType dbl_type;
+ DoublePropType dbl_type;
prop_value = dbl_type.CreateValue(5.5, nullptr);
EXPECT_DOUBLE_EQ(5.5, PropValueToDBusVariant(prop_value.get()).Get<double>());
- buffet::StringPropType str_type;
+ StringPropType str_type;
prop_value = str_type.CreateValue(std::string{"foo"}, nullptr);
EXPECT_EQ("foo", PropValueToDBusVariant(prop_value.get()).Get<std::string>());
- buffet::ObjectPropType obj_type;
+ ObjectPropType obj_type;
ASSERT_TRUE(obj_type.FromJson(CreateDictionaryValue(
"{'properties':{'width':'integer','height':'integer'},"
"'enum':[{'width':10,'height':20},{'width':100,'height':200}]}").get(),
nullptr, nullptr));
- buffet::native_types::Object obj{
- {"width", int_type.CreateValue(10, nullptr)},
- {"height", int_type.CreateValue(20, nullptr)},
+ native_types::Object obj{
+ {"width", int_type.CreateValue(10, nullptr)},
+ {"height", int_type.CreateValue(20, nullptr)},
};
prop_value = obj_type.CreateValue(obj, nullptr);
VariantDictionary dict =
@@ -250,9 +248,9 @@
EXPECT_EQ(20, dict["height"].Get<int>());
EXPECT_EQ(10, dict["width"].Get<int>());
- buffet::ArrayPropType arr_type;
+ ArrayPropType arr_type;
arr_type.SetItemType(str_type.Clone());
- buffet::native_types::Array arr;
+ native_types::Array arr;
arr.push_back(str_type.CreateValue(std::string{"foo"}, nullptr));
arr.push_back(str_type.CreateValue(std::string{"bar"}, nullptr));
arr.push_back(str_type.CreateValue(std::string{"baz"}, nullptr));
@@ -264,7 +262,7 @@
}
TEST(CommandSchemaUtils, PropValueFromDBusVariant_Int) {
- buffet::IntPropType int_type;
+ IntPropType int_type;
ASSERT_TRUE(int_type.FromJson(CreateDictionaryValue("{'enum':[1,2]}").get(),
nullptr, nullptr));
@@ -276,11 +274,11 @@
prop_value = PropValueFromDBusVariant(&int_type, 5, &error);
EXPECT_EQ(nullptr, prop_value.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
}
TEST(CommandSchemaUtils, PropValueFromDBusVariant_Bool) {
- buffet::BooleanPropType bool_type;
+ BooleanPropType bool_type;
ASSERT_TRUE(bool_type.FromJson(CreateDictionaryValue("{'enum':[true]}").get(),
nullptr, nullptr));
@@ -292,11 +290,11 @@
prop_value = PropValueFromDBusVariant(&bool_type, false, &error);
EXPECT_EQ(nullptr, prop_value.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
}
TEST(CommandSchemaUtils, PropValueFromDBusVariant_Double) {
- buffet::DoublePropType dbl_type;
+ DoublePropType dbl_type;
ASSERT_TRUE(dbl_type.FromJson(CreateDictionaryValue("{'maximum':2.0}").get(),
nullptr, nullptr));
@@ -308,11 +306,11 @@
prop_value = PropValueFromDBusVariant(&dbl_type, 10.0, &error);
EXPECT_EQ(nullptr, prop_value.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
}
TEST(CommandSchemaUtils, PropValueFromDBusVariant_String) {
- buffet::StringPropType str_type;
+ StringPropType str_type;
ASSERT_TRUE(str_type.FromJson(CreateDictionaryValue("{'minLength': 4}").get(),
nullptr, nullptr));
@@ -325,11 +323,11 @@
prop_value = PropValueFromDBusVariant(&str_type, std::string{"foo"}, &error);
EXPECT_EQ(nullptr, prop_value.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
}
TEST(CommandSchemaUtils, PropValueFromDBusVariant_Object) {
- buffet::ObjectPropType obj_type;
+ ObjectPropType obj_type;
ASSERT_TRUE(obj_type.FromJson(CreateDictionaryValue(
"{'properties':{'width':'integer','height':'integer'},"
"'enum':[{'width':10,'height':20},{'width':100,'height':200}]}").get(),
@@ -341,7 +339,7 @@
};
auto prop_value = PropValueFromDBusVariant(&obj_type, obj, nullptr);
ASSERT_NE(nullptr, prop_value.get());
- auto value = prop_value->GetValueAsAny().Get<buffet::native_types::Object>();
+ auto value = prop_value->GetValueAsAny().Get<native_types::Object>();
EXPECT_EQ(100, value["width"].get()->GetValueAsAny().Get<int>());
EXPECT_EQ(200, value["height"].get()->GetValueAsAny().Get<int>());
@@ -350,18 +348,18 @@
prop_value = PropValueFromDBusVariant(&obj_type, obj, &error);
EXPECT_EQ(nullptr, prop_value.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
}
TEST(CommandSchemaUtils, PropValueFromDBusVariant_Array) {
- buffet::ArrayPropType arr_type;
- buffet::IntPropType int_type;
+ ArrayPropType arr_type;
+ IntPropType int_type;
int_type.AddMinMaxConstraint(0, 100);
arr_type.SetItemType(int_type.Clone());
std::vector<int> data{0, 1, 1, 100};
auto prop_value = PropValueFromDBusVariant(&arr_type, data, nullptr);
ASSERT_NE(nullptr, prop_value.get());
- auto arr = prop_value->GetValueAsAny().Get<buffet::native_types::Array>();
+ auto arr = prop_value->GetValueAsAny().Get<native_types::Array>();
ASSERT_EQ(4u, arr.size());
EXPECT_EQ(0, arr[0]->GetInt()->GetValue());
EXPECT_EQ(1, arr[1]->GetInt()->GetValue());
@@ -373,5 +371,7 @@
prop_value = PropValueFromDBusVariant(&arr_type, data, &error);
EXPECT_EQ(nullptr, prop_value.get());
ASSERT_NE(nullptr, error.get());
- EXPECT_EQ(buffet::errors::commands::kOutOfRange, error->GetCode());
+ EXPECT_EQ(errors::commands::kOutOfRange, error->GetCode());
}
+
+} // namespace buffet
diff --git a/buffet/device_registration_info_unittest.cc b/buffet/device_registration_info_unittest.cc
index 0deaa6e..f82a39b 100644
--- a/buffet/device_registration_info_unittest.cc
+++ b/buffet/device_registration_info_unittest.cc
@@ -21,12 +21,12 @@
#include "buffet/states/state_manager.h"
#include "buffet/storage_impls.h"
+namespace buffet {
+
using chromeos::http::request_header::kAuthorization;
using chromeos::http::fake::ServerRequest;
using chromeos::http::fake::ServerResponse;
-namespace buffet {
-
namespace {
namespace test_data {
@@ -313,8 +313,7 @@
EXPECT_FALSE(DeviceRegistrationInfo::TestHelper::CheckRegistration(
dev_reg_.get(), &error));
EXPECT_EQ(1, transport_->GetRequestCount());
- EXPECT_TRUE(error->HasError(buffet::kErrorDomainOAuth2,
- "unable_to_authenticate"));
+ EXPECT_TRUE(error->HasError(kErrorDomainOAuth2, "unable_to_authenticate"));
EXPECT_EQ(RegistrationStatus::kConnecting, dev_reg_->GetRegistrationStatus());
}
@@ -332,8 +331,7 @@
EXPECT_FALSE(DeviceRegistrationInfo::TestHelper::CheckRegistration(
dev_reg_.get(), &error));
EXPECT_EQ(1, transport_->GetRequestCount());
- EXPECT_TRUE(error->HasError(buffet::kErrorDomainOAuth2,
- "invalid_grant"));
+ EXPECT_TRUE(error->HasError(kErrorDomainOAuth2, "invalid_grant"));
EXPECT_EQ(RegistrationStatus::kInvalidCredentials,
dev_reg_->GetRegistrationStatus());
}
@@ -402,11 +400,12 @@
base::DictionaryValue* commandDefs = nullptr;
EXPECT_TRUE(json->GetDictionary("deviceDraft.commandDefs", &commandDefs));
EXPECT_FALSE(commandDefs->empty());
- EXPECT_EQ("{'base':{'reboot':{'parameters':{"
- "'delay':{'minimum':10,'type':'integer'}}}},"
- "'robot':{'_jump':{'parameters':{"
- "'_height':{'type':'integer'}}}}}",
- buffet::unittests::ValueToString(commandDefs));
+ EXPECT_EQ(
+ "{'base':{'reboot':{'parameters':{"
+ "'delay':{'minimum':10,'type':'integer'}}}},"
+ "'robot':{'_jump':{'parameters':{"
+ "'_height':{'type':'integer'}}}}}",
+ unittests::ValueToString(commandDefs));
base::DictionaryValue json_resp;
json_resp.SetString("id", test_data::kClaimTicketId);
@@ -422,7 +421,7 @@
response->ReplyJson(chromeos::http::status_code::Ok, &json_resp);
};
- auto json_base = buffet::unittests::CreateDictionaryValue(R"({
+ auto json_base = unittests::CreateDictionaryValue(R"({
'base': {
'reboot': {
'parameters': {'delay': 'integer'},
@@ -435,7 +434,7 @@
}
})");
EXPECT_TRUE(command_manager_->LoadBaseCommands(*json_base, nullptr));
- auto json_cmds = buffet::unittests::CreateDictionaryValue(R"({
+ auto json_cmds = unittests::CreateDictionaryValue(R"({
'base': {
'reboot': {
'parameters': {'delay': {'minimum': 10}},
@@ -504,7 +503,7 @@
TEST_F(DeviceRegistrationInfoTest, UpdateCommand) {
EXPECT_TRUE(dev_reg_->Load());
- auto json_cmds = buffet::unittests::CreateDictionaryValue(R"({
+ auto json_cmds = unittests::CreateDictionaryValue(R"({
'robot': {
'_jump': {
'parameters': {'_height': 'integer'},
@@ -516,7 +515,7 @@
const std::string command_url = dev_reg_->GetServiceURL("commands/1234");
- auto commands_json = buffet::unittests::CreateValue(R"([{
+ auto commands_json = unittests::CreateValue(R"([{
'name':'robot._jump',
'id':'1234',
'parameters': {'_height': 100}
diff --git a/buffet/states/state_manager_unittest.cc b/buffet/states/state_manager_unittest.cc
index b035175..12d3845 100644
--- a/buffet/states/state_manager_unittest.cc
+++ b/buffet/states/state_manager_unittest.cc
@@ -16,13 +16,13 @@
#include "buffet/states/error_codes.h"
#include "buffet/states/mock_state_change_queue_interface.h"
-using buffet::unittests::CreateDictionaryValue;
-using buffet::unittests::ValueToString;
-using testing::Return;
-using testing::_;
-
namespace buffet {
+using testing::_;
+using testing::Return;
+using unittests::CreateDictionaryValue;
+using unittests::ValueToString;
+
namespace {
std::unique_ptr<base::DictionaryValue> GetTestSchema() {
return CreateDictionaryValue(R"({
diff --git a/buffet/states/state_package_unittest.cc b/buffet/states/state_package_unittest.cc
index d2d36e4..7856531 100644
--- a/buffet/states/state_package_unittest.cc
+++ b/buffet/states/state_package_unittest.cc
@@ -15,11 +15,11 @@
#include "buffet/commands/unittest_utils.h"
#include "buffet/states/error_codes.h"
-using buffet::unittests::CreateDictionaryValue;
-using buffet::unittests::ValueToString;
-
namespace buffet {
+using unittests::CreateDictionaryValue;
+using unittests::ValueToString;
+
class StatePackageTestHelper {
public:
// Returns the state property definitions (types/constraints/etc).
diff --git a/buffet/xmpp/xmpp_client_unittest.cc b/buffet/xmpp/xmpp_client_unittest.cc
index ef26f2e..26dfacf 100644
--- a/buffet/xmpp/xmpp_client_unittest.cc
+++ b/buffet/xmpp/xmpp_client_unittest.cc
@@ -13,13 +13,13 @@
#include "buffet/xmpp/xmpp_client.h"
#include "buffet/xmpp/xmpp_connection.h"
+namespace buffet {
+
using ::testing::DoAll;
using ::testing::Return;
using ::testing::SetArgPointee;
using ::testing::_;
-namespace buffet {
-
namespace {
constexpr char kAccountName[] = "Account@Name";