Skip to content

Commit

Permalink
[AdTagging] Make a filter tool test deterministic
Browse files Browse the repository at this point in the history
The MatchRules test had non-deterministic sorting behavior on
different platforms. Fix this by avoiding situations in the test where
there are ties for the number of matches.

Bug: 878328, 877148
Change-Id: I4883141c0c5c8ab02ace9365b4a446f132d6cea1
Reviewed-on: https://chromium-review.googlesource.com/1193902
Commit-Queue: Josh Karlin <jkarlin@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586697}
  • Loading branch information
Josh Karlin authored and Commit Bot committed Aug 28, 2018
1 parent 84e3939 commit f4d9a94
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/subresource_filter/tools/filter_tool_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ TEST_F(FilterToolTest, MatchRules) {
"http://example.com/disallowed1.png", "image")
<< CreateJsonLine("http://example.com",
"http://example.com/disallowed2.png", "image")
<< CreateJsonLine(
"http://example.com",
"http://example.com/whitelist/disallowed2.png", "image")
<< CreateJsonLine("http://example.com",
"http://example.com/disallowed1.png", "image")
<< CreateJsonLine(
"http://example.com",
"http://example.com/whitelist/disallowed2.png", "image");
Expand All @@ -142,8 +147,8 @@ TEST_F(FilterToolTest, MatchRules) {
std::string result = out_stream_.str();

std::string expected =
"2 disallowed1.png|\n"
"1 @@whitelist/disallowed2.png|\n"
"3 disallowed1.png|\n"
"2 @@whitelist/disallowed2.png|\n"
"1 disallowed2.png|\n";

EXPECT_EQ(expected, out_stream_.str());
Expand Down

0 comments on commit f4d9a94

Please sign in to comment.