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

Side by Side Diff: base/property_bag_unittest.cc

Issue 10831407: Kill PropertyBag, switch WebContents to SupportsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/property_bag.cc ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/property_bag.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace base {
9
10 TEST(PropertyBagTest, AddQueryRemove) {
11 PropertyBag bag;
12 PropertyAccessor<int> adaptor;
13
14 // Should be no match initially.
15 EXPECT_TRUE(adaptor.GetProperty(&bag) == NULL);
16
17 // Add the value and make sure we get it back.
18 const int kFirstValue = 1;
19 adaptor.SetProperty(&bag, kFirstValue);
20 ASSERT_TRUE(adaptor.GetProperty(&bag));
21 EXPECT_EQ(kFirstValue, *adaptor.GetProperty(&bag));
22
23 // Set it to a new value.
24 const int kSecondValue = 2;
25 adaptor.SetProperty(&bag, kSecondValue);
26 ASSERT_TRUE(adaptor.GetProperty(&bag));
27 EXPECT_EQ(kSecondValue, *adaptor.GetProperty(&bag));
28
29 // Remove the value and make sure it's gone.
30 adaptor.DeleteProperty(&bag);
31 EXPECT_TRUE(adaptor.GetProperty(&bag) == NULL);
32 }
33
34 TEST(PropertyBagTest, Copy) {
35 PropertyAccessor<int> adaptor1;
36 PropertyAccessor<double> adaptor2;
37
38 // Create a bag with property type 1 in it.
39 PropertyBag copy;
40 adaptor1.SetProperty(&copy, 22);
41
42 const int kType1Value = 10;
43 const double kType2Value = 2.7;
44 {
45 // Create a bag with property types 1 and 2 in it.
46 PropertyBag initial;
47 adaptor1.SetProperty(&initial, kType1Value);
48 adaptor2.SetProperty(&initial, kType2Value);
49
50 // Assign to the original.
51 copy = initial;
52 }
53
54 // Verify the copy got the two properties.
55 ASSERT_TRUE(adaptor1.GetProperty(&copy));
56 ASSERT_TRUE(adaptor2.GetProperty(&copy));
57 EXPECT_EQ(kType1Value, *adaptor1.GetProperty(&copy));
58 EXPECT_EQ(kType2Value, *adaptor2.GetProperty(&copy));
59
60 // Clear it out, neither property should be left.
61 copy = PropertyBag();
62 EXPECT_TRUE(adaptor1.GetProperty(&copy) == NULL);
63 EXPECT_TRUE(adaptor2.GetProperty(&copy) == NULL);
64 }
65
66 } // namespace base
OLDNEW
« no previous file with comments | « base/property_bag.cc ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698