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

Unified Diff: components/policy/core/browser/android/app_restrictions_importer_unittest.cc

Issue 1220683008: Move AppRestriction to Policy code out of //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more build errors Created 5 years, 5 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
Index: components/policy/core/browser/android/app_restrictions_importer_unittest.cc
diff --git a/chrome/browser/android/policy/policy_manager_unittest.cc b/components/policy/core/browser/android/app_restrictions_importer_unittest.cc
similarity index 76%
rename from chrome/browser/android/policy/policy_manager_unittest.cc
rename to components/policy/core/browser/android/app_restrictions_importer_unittest.cc
index 99967b52a93890bf43c17cbb2d960c3abff2941c..d94f905fe3b42991f3621317198528a8a80d6e1e 100644
--- a/chrome/browser/android/policy/policy_manager_unittest.cc
+++ b/components/policy/core/browser/android/app_restrictions_importer_unittest.cc
@@ -4,7 +4,7 @@
#include "base/json/json_writer.h"
#include "base/values.h"
-#include "chrome/browser/android/policy/policy_manager.h"
+#include "components/policy/core/browser/android/app_restrictions_importer.h"
#include "components/policy/core/common/schema.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,7 +14,9 @@ using base::ListValue;
using base::StringValue;
using base::Value;
-class PolicyManagerTest : public testing::Test {
+namespace policy {
+
+class AppRestrictionsImporterTest : public testing::Test {
public:
void SetUp() override {
const char kSchemaTemplate[] =
@@ -35,16 +37,17 @@ class PolicyManagerTest : public testing::Test {
"}";
std::string error;
- schema_ = policy::Schema::Parse(kSchemaTemplate, &error);
+ schema_ = Schema::Parse(kSchemaTemplate, &error);
ASSERT_TRUE(schema_.valid()) << error;
}
protected:
// Converts the passed in value to the passed in schema, and serializes the
// result to JSON, to make it easier to compare with EXPECT_EQ.
- std::string Convert(Value* value, const policy::Schema& value_schema) {
+ std::string Convert(Value* value, const Schema& value_schema) {
scoped_ptr<Value> converted_value(
- PolicyManager::ConvertValueToSchema(value, value_schema));
+ AppRestrictionsImporter::ConvertValueToSchema(scoped_ptr<Value>(value),
+ value_schema));
std::string json_string;
EXPECT_TRUE(
@@ -52,18 +55,18 @@ class PolicyManagerTest : public testing::Test {
return json_string;
}
- policy::Schema schema_;
+ Schema schema_;
};
-TEST_F(PolicyManagerTest, ConvertToNullValue) {
- policy::Schema null_schema = schema_.GetKnownProperty("null");
+TEST_F(AppRestrictionsImporterTest, ConvertToNullValue) {
+ Schema null_schema = schema_.GetKnownProperty("null");
ASSERT_TRUE(null_schema.valid());
EXPECT_EQ("null", Convert(new StringValue("foo"), null_schema));
}
-TEST_F(PolicyManagerTest, ConvertToBoolValue) {
- policy::Schema bool_schema = schema_.GetKnownProperty("bool");
+TEST_F(AppRestrictionsImporterTest, ConvertToBoolValue) {
+ Schema bool_schema = schema_.GetKnownProperty("bool");
ASSERT_TRUE(bool_schema.valid());
EXPECT_EQ("true", Convert(new FundamentalValue(true), bool_schema));
@@ -79,8 +82,8 @@ TEST_F(PolicyManagerTest, ConvertToBoolValue) {
EXPECT_EQ("{}", Convert(new DictionaryValue(), bool_schema));
}
-TEST_F(PolicyManagerTest, ConvertToIntValue) {
- policy::Schema int_schema = schema_.GetKnownProperty("int");
+TEST_F(AppRestrictionsImporterTest, ConvertToIntValue) {
+ Schema int_schema = schema_.GetKnownProperty("int");
ASSERT_TRUE(int_schema.valid());
EXPECT_EQ("23", Convert(new FundamentalValue(23), int_schema));
@@ -90,8 +93,8 @@ TEST_F(PolicyManagerTest, ConvertToIntValue) {
EXPECT_EQ("false", Convert(new FundamentalValue(false), int_schema));
}
-TEST_F(PolicyManagerTest, ConvertToDoubleValue) {
- policy::Schema double_schema = schema_.GetKnownProperty("double");
+TEST_F(AppRestrictionsImporterTest, ConvertToDoubleValue) {
+ Schema double_schema = schema_.GetKnownProperty("double");
ASSERT_TRUE(double_schema.valid());
EXPECT_EQ("3", Convert(new FundamentalValue(3), double_schema));
@@ -101,16 +104,16 @@ TEST_F(PolicyManagerTest, ConvertToDoubleValue) {
EXPECT_EQ("true", Convert(new FundamentalValue(true), double_schema));
}
-TEST_F(PolicyManagerTest, ConvertToStringValue) {
- policy::Schema string_schema = schema_.GetKnownProperty("string");
+TEST_F(AppRestrictionsImporterTest, ConvertToStringValue) {
+ Schema string_schema = schema_.GetKnownProperty("string");
ASSERT_TRUE(string_schema.valid());
EXPECT_EQ("\"troz\"", Convert(new StringValue("troz"), string_schema));
EXPECT_EQ("4711", Convert(new FundamentalValue(4711), string_schema));
}
-TEST_F(PolicyManagerTest, ConvertToListValue) {
- policy::Schema list_schema = schema_.GetKnownProperty("list");
+TEST_F(AppRestrictionsImporterTest, ConvertToListValue) {
+ Schema list_schema = schema_.GetKnownProperty("list");
ASSERT_TRUE(list_schema.valid());
ListValue* list = new ListValue;
@@ -123,8 +126,8 @@ TEST_F(PolicyManagerTest, ConvertToListValue) {
EXPECT_EQ("19", Convert(new FundamentalValue(19), list_schema));
}
-TEST_F(PolicyManagerTest, ConvertToDictionaryValue) {
- policy::Schema dict_schema = schema_.GetKnownProperty("dict");
+TEST_F(AppRestrictionsImporterTest, ConvertToDictionaryValue) {
+ Schema dict_schema = schema_.GetKnownProperty("dict");
ASSERT_TRUE(dict_schema.valid());
DictionaryValue* dict = new DictionaryValue;
@@ -135,3 +138,5 @@ TEST_F(PolicyManagerTest, ConvertToDictionaryValue) {
EXPECT_EQ("\"fnord\"", Convert(new StringValue("fnord"), dict_schema));
EXPECT_EQ("1729", Convert(new FundamentalValue(1729), dict_schema));
}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698