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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_apitest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 Mock::VerifyAndClearExpectations(&observer); 435 Mock::VerifyAndClearExpectations(&observer);
436 registry->RemoveObserver(&observer); 436 registry->RemoveObserver(&observer);
437 437
438 // Verify that its schema has been published, and verify its contents. 438 // Verify that its schema has been published, and verify its contents.
439 const policy::Schema* schema = 439 const policy::Schema* schema =
440 registry->schema_map()->GetSchema(policy::PolicyNamespace( 440 registry->schema_map()->GetSchema(policy::PolicyNamespace(
441 policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)); 441 policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId));
442 ASSERT_TRUE(schema); 442 ASSERT_TRUE(schema);
443 443
444 ASSERT_TRUE(schema->valid()); 444 ASSERT_TRUE(schema->valid());
445 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema->type()); 445 ASSERT_EQ(base::Value::Type::DICTIONARY, schema->type());
446 ASSERT_TRUE(schema->GetKnownProperty("string-policy").valid()); 446 ASSERT_TRUE(schema->GetKnownProperty("string-policy").valid());
447 EXPECT_EQ(base::Value::TYPE_STRING, 447 EXPECT_EQ(base::Value::Type::STRING,
448 schema->GetKnownProperty("string-policy").type()); 448 schema->GetKnownProperty("string-policy").type());
449 ASSERT_TRUE(schema->GetKnownProperty("int-policy").valid()); 449 ASSERT_TRUE(schema->GetKnownProperty("int-policy").valid());
450 EXPECT_EQ(base::Value::TYPE_INTEGER, 450 EXPECT_EQ(base::Value::Type::INTEGER,
451 schema->GetKnownProperty("int-policy").type()); 451 schema->GetKnownProperty("int-policy").type());
452 ASSERT_TRUE(schema->GetKnownProperty("double-policy").valid()); 452 ASSERT_TRUE(schema->GetKnownProperty("double-policy").valid());
453 EXPECT_EQ(base::Value::TYPE_DOUBLE, 453 EXPECT_EQ(base::Value::Type::DOUBLE,
454 schema->GetKnownProperty("double-policy").type()); 454 schema->GetKnownProperty("double-policy").type());
455 ASSERT_TRUE(schema->GetKnownProperty("boolean-policy").valid()); 455 ASSERT_TRUE(schema->GetKnownProperty("boolean-policy").valid());
456 EXPECT_EQ(base::Value::TYPE_BOOLEAN, 456 EXPECT_EQ(base::Value::Type::BOOLEAN,
457 schema->GetKnownProperty("boolean-policy").type()); 457 schema->GetKnownProperty("boolean-policy").type());
458 458
459 policy::Schema list = schema->GetKnownProperty("list-policy"); 459 policy::Schema list = schema->GetKnownProperty("list-policy");
460 ASSERT_TRUE(list.valid()); 460 ASSERT_TRUE(list.valid());
461 ASSERT_EQ(base::Value::TYPE_LIST, list.type()); 461 ASSERT_EQ(base::Value::Type::LIST, list.type());
462 ASSERT_TRUE(list.GetItems().valid()); 462 ASSERT_TRUE(list.GetItems().valid());
463 EXPECT_EQ(base::Value::TYPE_STRING, list.GetItems().type()); 463 EXPECT_EQ(base::Value::Type::STRING, list.GetItems().type());
464 464
465 policy::Schema dict = schema->GetKnownProperty("dict-policy"); 465 policy::Schema dict = schema->GetKnownProperty("dict-policy");
466 ASSERT_TRUE(dict.valid()); 466 ASSERT_TRUE(dict.valid());
467 ASSERT_EQ(base::Value::TYPE_DICTIONARY, dict.type()); 467 ASSERT_EQ(base::Value::Type::DICTIONARY, dict.type());
468 list = dict.GetKnownProperty("list"); 468 list = dict.GetKnownProperty("list");
469 ASSERT_TRUE(list.valid()); 469 ASSERT_TRUE(list.valid());
470 ASSERT_EQ(base::Value::TYPE_LIST, list.type()); 470 ASSERT_EQ(base::Value::Type::LIST, list.type());
471 dict = list.GetItems(); 471 dict = list.GetItems();
472 ASSERT_TRUE(dict.valid()); 472 ASSERT_TRUE(dict.valid());
473 ASSERT_EQ(base::Value::TYPE_DICTIONARY, dict.type()); 473 ASSERT_EQ(base::Value::Type::DICTIONARY, dict.type());
474 ASSERT_TRUE(dict.GetProperty("anything").valid()); 474 ASSERT_TRUE(dict.GetProperty("anything").valid());
475 EXPECT_EQ(base::Value::TYPE_INTEGER, dict.GetProperty("anything").type()); 475 EXPECT_EQ(base::Value::Type::INTEGER, dict.GetProperty("anything").type());
476 } 476 }
477 477
478 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ManagedStorage) { 478 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ManagedStorage) {
479 // Set policies for the test extension. 479 // Set policies for the test extension.
480 std::unique_ptr<base::DictionaryValue> policy = 480 std::unique_ptr<base::DictionaryValue> policy =
481 extensions::DictionaryBuilder() 481 extensions::DictionaryBuilder()
482 .Set("string-policy", "value") 482 .Set("string-policy", "value")
483 .Set("int-policy", -123) 483 .Set("int-policy", -123)
484 .Set("double-policy", 456e7) 484 .Set("double-policy", 456e7)
485 .SetBoolean("boolean-policy", true) 485 .SetBoolean("boolean-policy", true)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // Disable the 'managed' namespace. 564 // Disable the 'managed' namespace.
565 StorageFrontend* frontend = StorageFrontend::Get(browser()->profile()); 565 StorageFrontend* frontend = StorageFrontend::Get(browser()->profile());
566 frontend->DisableStorageForTesting(MANAGED); 566 frontend->DisableStorageForTesting(MANAGED);
567 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); 567 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED));
568 // Now run the extension. 568 // Now run the extension.
569 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) 569 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled"))
570 << message_; 570 << message_;
571 } 571 }
572 572
573 } // namespace extensions 573 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698