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

Side by Side Diff: base/values_unittest.cc

Issue 5213002: Fix for Bug 50726 "Save extension list and "winning" prefs from extensions" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Same patch but without stuff that is already included in 5204006 Created 10 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 | Annotate | Revision Log
« no previous file with comments | « base/values.cc ('k') | chrome/browser/extensions/extension_pref_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <limits> 5 #include <limits>
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 EXPECT_FALSE(dv.Equals(copy.get())); 501 EXPECT_FALSE(dv.Equals(copy.get()));
502 502
503 // Check if Equals detects differences in only the keys. 503 // Check if Equals detects differences in only the keys.
504 copy.reset(static_cast<DictionaryValue*>(dv.DeepCopy())); 504 copy.reset(static_cast<DictionaryValue*>(dv.DeepCopy()));
505 EXPECT_TRUE(dv.Equals(copy.get())); 505 EXPECT_TRUE(dv.Equals(copy.get()));
506 copy->Remove("a", NULL); 506 copy->Remove("a", NULL);
507 copy->SetBoolean("aa", false); 507 copy->SetBoolean("aa", false);
508 EXPECT_FALSE(dv.Equals(copy.get())); 508 EXPECT_FALSE(dv.Equals(copy.get()));
509 } 509 }
510 510
511 TEST_F(ValuesTest, StaticEquals) {
512 scoped_ptr<Value> null1(Value::CreateNullValue());
513 scoped_ptr<Value> null2(Value::CreateNullValue());
514 EXPECT_TRUE(Value::Equals(null1.get(), null2.get()));
515 EXPECT_TRUE(Value::Equals(NULL, NULL));
516
517 scoped_ptr<Value> i42(Value::CreateIntegerValue(42));
518 scoped_ptr<Value> j42(Value::CreateIntegerValue(42));
519 scoped_ptr<Value> i17(Value::CreateIntegerValue(17));
520 EXPECT_TRUE(Value::Equals(i42.get(), i42.get()));
521 EXPECT_TRUE(Value::Equals(j42.get(), i42.get()));
522 EXPECT_TRUE(Value::Equals(i42.get(), j42.get()));
523 EXPECT_FALSE(Value::Equals(i42.get(), i17.get()));
524 EXPECT_FALSE(Value::Equals(i42.get(), NULL));
525 EXPECT_FALSE(Value::Equals(NULL, i42.get()));
526
527 // NULL and Value::CreateNullValue() are intentionally different: We need
528 // support for NULL as a return value for "undefined" without caring for
529 // ownership of the pointer.
530 EXPECT_FALSE(Value::Equals(null1.get(), NULL));
531 EXPECT_FALSE(Value::Equals(NULL, null1.get()));
532 }
533
511 TEST_F(ValuesTest, RemoveEmptyChildren) { 534 TEST_F(ValuesTest, RemoveEmptyChildren) {
512 scoped_ptr<DictionaryValue> root(new DictionaryValue); 535 scoped_ptr<DictionaryValue> root(new DictionaryValue);
513 // Remove empty lists and dictionaries. 536 // Remove empty lists and dictionaries.
514 root->Set("empty_dict", new DictionaryValue); 537 root->Set("empty_dict", new DictionaryValue);
515 root->Set("empty_list", new ListValue); 538 root->Set("empty_list", new ListValue);
516 root->SetWithoutPathExpansion("a.b.c.d.e", new DictionaryValue); 539 root->SetWithoutPathExpansion("a.b.c.d.e", new DictionaryValue);
517 root.reset(root->DeepCopyWithoutEmptyChildren()); 540 root.reset(root->DeepCopyWithoutEmptyChildren());
518 EXPECT_TRUE(root->empty()); 541 EXPECT_TRUE(root->empty());
519 542
520 // Make sure we don't prune too much. 543 // Make sure we don't prune too much.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 "s1", 754 "s1",
732 "s1.s2" 755 "s1.s2"
733 }; 756 };
734 dict1.reset(new DictionaryValue()); 757 dict1.reset(new DictionaryValue());
735 dict1->Set("s1.s2", new DictionaryValue()); 758 dict1->Set("s1.s2", new DictionaryValue());
736 dict2.reset(new DictionaryValue()); 759 dict2.reset(new DictionaryValue());
737 dict2->SetInteger("s1", 1); 760 dict2->SetInteger("s1", 1);
738 CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths8, 761 CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths8,
739 arraysize(expected_paths8)); 762 arraysize(expected_paths8));
740 } 763 }
OLDNEW
« no previous file with comments | « base/values.cc ('k') | chrome/browser/extensions/extension_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698