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

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: Addressed comments, moved ExtensionPrefStore reference to Profile 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
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 Value* null_ptr = NULL;
Mattias Nissler (ping if slow) 2010/12/01 10:36:36 Why have a var for this that even has more charact
battre (please use the other) 2010/12/01 17:44:38 Done.
513 scoped_ptr<Value> null1(Value::CreateNullValue());
514 scoped_ptr<Value> null2(Value::CreateNullValue());
515 EXPECT_TRUE(Value::Equals(null1.get(), null2.get()));
516 EXPECT_TRUE(Value::Equals(null_ptr, null_ptr));
517
518 scoped_ptr<Value> i42(Value::CreateIntegerValue(42));
519 scoped_ptr<Value> j42(Value::CreateIntegerValue(42));
520 scoped_ptr<Value> i17(Value::CreateIntegerValue(17));
521 EXPECT_TRUE(Value::Equals(i42.get(), i42.get()));
522 EXPECT_TRUE(Value::Equals(j42.get(), i42.get()));
523 EXPECT_TRUE(Value::Equals(i42.get(), j42.get()));
524 EXPECT_FALSE(Value::Equals(i42.get(), i17.get()));
525 EXPECT_FALSE(Value::Equals(i42.get(), null_ptr));
526 EXPECT_FALSE(Value::Equals(null_ptr, i42.get()));
527
528 // NULL and Value::CreateNullValue() are intentionally different: We need
529 // support for NULL as a return value for "undefined" without caring for
530 // ownership of the pointer.
531 EXPECT_FALSE(Value::Equals(null1.get(), null_ptr));
532 EXPECT_FALSE(Value::Equals(null_ptr, null1.get()));
533 }
534
511 TEST_F(ValuesTest, RemoveEmptyChildren) { 535 TEST_F(ValuesTest, RemoveEmptyChildren) {
512 scoped_ptr<DictionaryValue> root(new DictionaryValue); 536 scoped_ptr<DictionaryValue> root(new DictionaryValue);
513 // Remove empty lists and dictionaries. 537 // Remove empty lists and dictionaries.
514 root->Set("empty_dict", new DictionaryValue); 538 root->Set("empty_dict", new DictionaryValue);
515 root->Set("empty_list", new ListValue); 539 root->Set("empty_list", new ListValue);
516 root->SetWithoutPathExpansion("a.b.c.d.e", new DictionaryValue); 540 root->SetWithoutPathExpansion("a.b.c.d.e", new DictionaryValue);
517 root.reset(root->DeepCopyWithoutEmptyChildren()); 541 root.reset(root->DeepCopyWithoutEmptyChildren());
518 EXPECT_TRUE(root->empty()); 542 EXPECT_TRUE(root->empty());
519 543
520 // Make sure we don't prune too much. 544 // Make sure we don't prune too much.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 "s1", 755 "s1",
732 "s1.s2" 756 "s1.s2"
733 }; 757 };
734 dict1.reset(new DictionaryValue()); 758 dict1.reset(new DictionaryValue());
735 dict1->Set("s1.s2", new DictionaryValue()); 759 dict1->Set("s1.s2", new DictionaryValue());
736 dict2.reset(new DictionaryValue()); 760 dict2.reset(new DictionaryValue());
737 dict2->SetInteger("s1", 1); 761 dict2->SetInteger("s1", 1);
738 CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths8, 762 CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths8,
739 arraysize(expected_paths8)); 763 arraysize(expected_paths8));
740 } 764 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698