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

Side by Side Diff: chrome/common/extensions/value_counter_unittest.cc

Issue 10514013: Filtered events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 80 char Created 8 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "base/values.h"
7 #include "chrome/common/extensions/value_counter.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 class ValueCounterUnittest : public testing::Test {
11 };
12
13 TEST_F(ValueCounterUnittest, TestAddingSameValue) {
14 extensions::ValueCounter vc;
15 scoped_ptr<base::Value> value(new ListValue());
battre 2012/06/20 09:50:46 nit: you can allocate this and the other value* va
koz (OOO until 15th September) 2012/06/21 02:23:11 Done.
16 ASSERT_EQ(1, vc.Add(*value));
17 ASSERT_EQ(2, vc.Add(*value));
18 }
19
20 TEST_F(ValueCounterUnittest, TestAddingDifferentValue) {
21 extensions::ValueCounter vc;
22 scoped_ptr<base::Value> value1(new ListValue());
23 scoped_ptr<base::Value> value2(new DictionaryValue());
24 ASSERT_EQ(1, vc.Add(*value1));
25 ASSERT_EQ(1, vc.Add(*value2));
26 }
27
28 TEST_F(ValueCounterUnittest, TestRemovingValue) {
29 extensions::ValueCounter vc;
30 scoped_ptr<base::Value> value(new ListValue());
31 ASSERT_EQ(1, vc.Add(*value));
32 ASSERT_EQ(2, vc.Add(*value));
33 ASSERT_EQ(1, vc.Remove(*value));
34 ASSERT_EQ(0, vc.Remove(*value));
35 }
36
37 TEST_F(ValueCounterUnittest, TestAddIfMissing) {
38 extensions::ValueCounter vc;
39 scoped_ptr<base::Value> value(new ListValue());
40 ASSERT_EQ(1, vc.AddIfMissing(*value));
41 ASSERT_EQ(1, vc.AddIfMissing(*value));
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698