Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/ReferrerMapping.cpp

Issue 5768603836088320: Issue 1564-Fix FilterEngine::Matches for allowing request which is whitelisted in the ascendant node
Left Patch Set: fix according to comments and add some tests Created Nov. 26, 2014, 10:35 a.m.
Right Patch Set: fix according to comments Created Dec. 12, 2014, 4:59 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/ReferrerMapping.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 referrerMapping.Add("first", "", FrameIndicator::FRAME_INDICATOR_FRAME); 48 referrerMapping.Add("first", "", FrameIndicator::FRAME_INDICATOR_FRAME);
49 std::vector<std::string> referrerChain = 49 std::vector<std::string> referrerChain =
50 referrerMapping.BuildFrameStructure("first"); 50 referrerMapping.BuildFrameStructure("first");
51 ASSERT_EQ(1, referrerChain.size()); 51 ASSERT_EQ(1, referrerChain.size());
52 EXPECT_EQ("first", referrerChain[0]); 52 EXPECT_EQ("first", referrerChain[0]);
53 } 53 }
54 54
55 TEST(ReferrerMappingTest, NotAFrame) 55 TEST(ReferrerMappingTest, NotAFrame)
56 { 56 {
57 AdblockPlus::ReferrerMapping referrerMapping; 57 AdblockPlus::ReferrerMapping referrerMapping;
58 referrerMapping.Add("first", "", FrameIndicator::FRAME_INDICATOR_NOT_A_FRAME); 58 referrerMapping.Add("first", "", FrameIndicator::FRAME_INDICATOR_NOT_FRAME);
59 std::vector<std::string> referrerChain = 59 std::vector<std::string> referrerChain =
60 referrerMapping.BuildFrameStructure("first"); 60 referrerMapping.BuildFrameStructure("first");
61 ASSERT_EQ(0, referrerChain.size()); 61 ASSERT_EQ(0, referrerChain.size());
62 } 62 }
63 63
64 TEST(ReferrerMappingTest, TwoElementReferrerChain) 64 TEST(ReferrerMappingTest, TwoElementReferrerChain)
65 { 65 {
66 AdblockPlus::ReferrerMapping referrerMapping; 66 AdblockPlus::ReferrerMapping referrerMapping;
67 referrerMapping.Add("second", "first", FrameIndicator::FRAME_INDICATOR_FRAME); 67 referrerMapping.Add("second", "first", FrameIndicator::FRAME_INDICATOR_FRAME);
68 std::vector<std::string> referrerChain = 68 std::vector<std::string> referrerChain =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ASSERT_EQ("fourth", referrerChain[2]); 117 ASSERT_EQ("fourth", referrerChain[2]);
118 ASSERT_EQ("fifth", referrerChain[3]); 118 ASSERT_EQ("fifth", referrerChain[3]);
119 ASSERT_EQ("sixth", referrerChain[4]); 119 ASSERT_EQ("sixth", referrerChain[4]);
120 ASSERT_EQ("seventh", referrerChain[5]); 120 ASSERT_EQ("seventh", referrerChain[5]);
121 } 121 }
122 122
123 TEST(ReferrerMappingTest, OnlyFrames) 123 TEST(ReferrerMappingTest, OnlyFrames)
124 { 124 {
125 AdblockPlus::ReferrerMapping referrerMapping; 125 AdblockPlus::ReferrerMapping referrerMapping;
126 referrerMapping.Add("iframe1", "root-page", FrameIndicator::FRAME_INDICATOR_FR AME); 126 referrerMapping.Add("iframe1", "root-page", FrameIndicator::FRAME_INDICATOR_FR AME);
127 referrerMapping.Add("not a frame", "iframe1", FrameIndicator::FRAME_INDICATOR_ NOT_A_FRAME); 127 referrerMapping.Add("not a frame", "iframe1", FrameIndicator::FRAME_INDICATOR_ NOT_FRAME);
128 referrerMapping.Add("iframe2", "not a frame", FrameIndicator::FRAME_INDICATOR_ FRAME); 128 referrerMapping.Add("iframe2", "not a frame", FrameIndicator::FRAME_INDICATOR_ FRAME);
129 referrerMapping.Add("media", "iframe2", FrameIndicator::FRAME_INDICATOR_NOT_A_ FRAME); 129 referrerMapping.Add("media", "iframe2", FrameIndicator::FRAME_INDICATOR_NOT_FR AME);
130 130
131 std::vector<std::string> referrerChain = referrerMapping.BuildFrameStructure(" media"); 131 std::vector<std::string> referrerChain = referrerMapping.BuildFrameStructure(" media");
132 ASSERT_EQ(3, referrerChain.size()); 132 ASSERT_EQ(3, referrerChain.size());
133 EXPECT_EQ("root-page", referrerChain[0]); 133 EXPECT_EQ("root-page", referrerChain[0]);
134 EXPECT_EQ("iframe1", referrerChain[1]); 134 EXPECT_EQ("iframe1", referrerChain[1]);
135 EXPECT_EQ("iframe2", referrerChain[2]); 135 EXPECT_EQ("iframe2", referrerChain[2]);
136 136
137 referrerMapping.Add("iframe3", "media", FrameIndicator::FRAME_INDICATOR_FRAME) ; 137 referrerMapping.Add("iframe3", "media", FrameIndicator::FRAME_INDICATOR_FRAME) ;
138 referrerChain = referrerMapping.BuildFrameStructure("iframe3"); 138 referrerChain = referrerMapping.BuildFrameStructure("iframe3");
139 ASSERT_EQ(4, referrerChain.size()); 139 ASSERT_EQ(4, referrerChain.size());
140 EXPECT_EQ("root-page", referrerChain[0]); 140 EXPECT_EQ("root-page", referrerChain[0]);
141 EXPECT_EQ("iframe1", referrerChain[1]); 141 EXPECT_EQ("iframe1", referrerChain[1]);
142 EXPECT_EQ("iframe2", referrerChain[2]); 142 EXPECT_EQ("iframe2", referrerChain[2]);
143 EXPECT_EQ("iframe3", referrerChain[3]); 143 EXPECT_EQ("iframe3", referrerChain[3]);
144 } 144 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld