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

Side by Side Diff: chrome/browser/extensions/process_map_unittest.cc

Issue 8769022: Add site_instance_id to ProcessMap::Item. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move Item into cc file Created 9 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) 2011 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/extensions/process_map.h" 5 #include "chrome/browser/extensions/process_map.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 using extensions::ProcessMap; 9 using extensions::ProcessMap;
10 10
11 TEST(ExtensionProcessMapTest, Test) { 11 TEST(ExtensionProcessMapTest, Test) {
12 ProcessMap map; 12 ProcessMap map;
13 13
14 // Test behavior when empty. 14 // Test behavior when empty.
15 EXPECT_FALSE(map.Contains("a", 1)); 15 EXPECT_FALSE(map.Contains("a", 1));
16 EXPECT_FALSE(map.Remove("a", 1)); 16 EXPECT_FALSE(map.Remove("a", 1, 1));
17 EXPECT_EQ(0u, map.size()); 17 EXPECT_EQ(0u, map.size());
18 18
19 // Test insertion and behavior with one item. 19 // Test insertion and behavior with one item.
20 EXPECT_TRUE(map.Insert("a", 1)); 20 EXPECT_TRUE(map.Insert("a", 1, 1));
21 EXPECT_TRUE(map.Contains("a", 1)); 21 EXPECT_TRUE(map.Contains("a", 1));
22 EXPECT_FALSE(map.Contains("a", 2)); 22 EXPECT_FALSE(map.Contains("a", 2));
23 EXPECT_FALSE(map.Contains("b", 1)); 23 EXPECT_FALSE(map.Contains("b", 1));
24 EXPECT_EQ(1u, map.size()); 24 EXPECT_EQ(1u, map.size());
25 25
26 // Test inserting a duplicate item. 26 // Test inserting a duplicate item.
27 EXPECT_FALSE(map.Insert("a", 1)); 27 EXPECT_FALSE(map.Insert("a", 1, 1));
28 EXPECT_TRUE(map.Contains("a", 1)); 28 EXPECT_TRUE(map.Contains("a", 1));
29 EXPECT_EQ(1u, map.size()); 29 EXPECT_EQ(1u, map.size());
30 30
31 // Insert some more items. 31 // Insert some more items.
32 EXPECT_TRUE(map.Insert("a", 2)); 32 EXPECT_TRUE(map.Insert("a", 2, 2));
33 EXPECT_TRUE(map.Insert("b", 1)); 33 EXPECT_TRUE(map.Insert("b", 1, 3));
34 EXPECT_TRUE(map.Insert("b", 2)); 34 EXPECT_TRUE(map.Insert("b", 2, 4));
35 EXPECT_EQ(4u, map.size()); 35 EXPECT_EQ(4u, map.size());
36 36
37 EXPECT_TRUE(map.Contains("a", 1)); 37 EXPECT_TRUE(map.Contains("a", 1));
38 EXPECT_TRUE(map.Contains("a", 2)); 38 EXPECT_TRUE(map.Contains("a", 2));
39 EXPECT_TRUE(map.Contains("b", 1)); 39 EXPECT_TRUE(map.Contains("b", 1));
40 EXPECT_TRUE(map.Contains("b", 2)); 40 EXPECT_TRUE(map.Contains("b", 2));
41 EXPECT_FALSE(map.Contains("a", 3)); 41 EXPECT_FALSE(map.Contains("a", 3));
42 42
43 // Test removal. 43 // Test removal.
44 EXPECT_TRUE(map.Remove("a", 1)); 44 EXPECT_TRUE(map.Remove("a", 1, 1));
45 EXPECT_FALSE(map.Remove("a", 1)); 45 EXPECT_FALSE(map.Remove("a", 1, 1));
46 EXPECT_EQ(3u, map.size()); 46 EXPECT_EQ(3u, map.size());
Charlie Reis 2011/12/02 00:45:11 Can you add Insert("a", 1, 2) somewhere above, and
Aaron Boodman 2011/12/02 05:32:45 Good point, done.
47 47
48 EXPECT_EQ(2, map.Remove(2)); 48 EXPECT_EQ(2, map.RemoveAllFromProcess(2));
49 EXPECT_EQ(1u, map.size()); 49 EXPECT_EQ(1u, map.size());
50 EXPECT_EQ(0, map.Remove(2)); 50 EXPECT_EQ(0, map.RemoveAllFromProcess(2));
51 EXPECT_EQ(1u, map.size()); 51 EXPECT_EQ(1u, map.size());
52 } 52 }
OLDNEW
« chrome/browser/extensions/process_map.h ('K') | « chrome/browser/extensions/process_map.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698