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

Side by Side Diff: test/WebRequest.cpp

Issue 29391770: Noissue - Fix sign comparison warnings in tests. (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created March 22, 2017, 3:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/ReferrerMapping.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 { 117 {
118 std::atomic<int> isConnectionAllowedCalledTimes(0); 118 std::atomic<int> isConnectionAllowedCalledTimes(0);
119 jsEngine->SetIsConnectionAllowedCallback([&isConnectionAllowedCalledTimes]()-> bool 119 jsEngine->SetIsConnectionAllowedCallback([&isConnectionAllowedCalledTimes]()-> bool
120 { 120 {
121 ++isConnectionAllowedCalledTimes; 121 ++isConnectionAllowedCalledTimes;
122 return true; 122 return true;
123 }); 123 });
124 jsEngine->Evaluate("_webRequest.GET('http://example.com/', {X: 'Y'}, function( result) {foo = result;} )"); 124 jsEngine->Evaluate("_webRequest.GET('http://example.com/', {X: 'Y'}, function( result) {foo = result;} )");
125 ASSERT_TRUE(jsEngine->Evaluate("this.foo")->IsUndefined()); 125 ASSERT_TRUE(jsEngine->Evaluate("this.foo")->IsUndefined());
126 AdblockPlus::Sleep(200); 126 AdblockPlus::Sleep(200);
127 EXPECT_EQ(1u, isConnectionAllowedCalledTimes); 127 EXPECT_EQ(1, isConnectionAllowedCalledTimes);
128 EXPECT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("foo.status")->As Int()); 128 EXPECT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("foo.status")->As Int());
129 EXPECT_EQ(123, jsEngine->Evaluate("foo.responseStatus")->AsInt()); 129 EXPECT_EQ(123, jsEngine->Evaluate("foo.responseStatus")->AsInt());
130 EXPECT_EQ("http://example.com/\nX\nY", jsEngine->Evaluate("foo.responseText")- >AsString()); 130 EXPECT_EQ("http://example.com/\nX\nY", jsEngine->Evaluate("foo.responseText")- >AsString());
131 EXPECT_EQ("{\"Foo\":\"Bar\"}", jsEngine->Evaluate("JSON.stringify(foo.response Headers)")->AsString()); 131 EXPECT_EQ("{\"Foo\":\"Bar\"}", jsEngine->Evaluate("JSON.stringify(foo.response Headers)")->AsString());
132 } 132 }
133 133
134 TEST_F(MockWebRequestTest, ConnectionIsNotAllowedOnJsEngine) 134 TEST_F(MockWebRequestTest, ConnectionIsNotAllowedOnJsEngine)
135 { 135 {
136 std::atomic<int> isConnectionAllowedCalledTimes(0); 136 std::atomic<int> isConnectionAllowedCalledTimes(0);
137 jsEngine->SetIsConnectionAllowedCallback([&isConnectionAllowedCalledTimes]()-> bool 137 jsEngine->SetIsConnectionAllowedCallback([&isConnectionAllowedCalledTimes]()-> bool
138 { 138 {
139 ++isConnectionAllowedCalledTimes; 139 ++isConnectionAllowedCalledTimes;
140 return false; 140 return false;
141 }); 141 });
142 jsEngine->Evaluate("_webRequest.GET('http://example.com/', {X: 'Y'}, function( result) {foo = result;} )"); 142 jsEngine->Evaluate("_webRequest.GET('http://example.com/', {X: 'Y'}, function( result) {foo = result;} )");
143 ASSERT_TRUE(jsEngine->Evaluate("this.foo")->IsUndefined()); 143 ASSERT_TRUE(jsEngine->Evaluate("this.foo")->IsUndefined());
144 AdblockPlus::Sleep(200); 144 AdblockPlus::Sleep(200);
145 EXPECT_EQ(1u, isConnectionAllowedCalledTimes); 145 EXPECT_EQ(1, isConnectionAllowedCalledTimes);
146 EXPECT_EQ(AdblockPlus::WebRequest::NS_ERROR_CONNECTION_REFUSED, jsEngine->Eval uate("foo.status")->AsInt()); 146 EXPECT_EQ(AdblockPlus::WebRequest::NS_ERROR_CONNECTION_REFUSED, jsEngine->Eval uate("foo.status")->AsInt());
147 EXPECT_EQ(0, jsEngine->Evaluate("foo.responseStatus")->AsInt()); 147 EXPECT_EQ(0, jsEngine->Evaluate("foo.responseStatus")->AsInt());
148 EXPECT_EQ("", jsEngine->Evaluate("foo.responseText")->AsString()); 148 EXPECT_EQ("", jsEngine->Evaluate("foo.responseText")->AsString());
149 EXPECT_EQ("{}", jsEngine->Evaluate("JSON.stringify(foo.responseHeaders)")->AsS tring()); 149 EXPECT_EQ("{}", jsEngine->Evaluate("JSON.stringify(foo.responseHeaders)")->AsS tring());
150 } 150 }
151 151
152 namespace 152 namespace
153 { 153 {
154 class SyncStrings 154 class SyncStrings
155 { 155 {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 catchLogSystem->clear(); 477 catchLogSystem->clear();
478 ResetTestXHR(jsEngine); 478 ResetTestXHR(jsEngine);
479 jsEngine->Evaluate("\ 479 jsEngine->Evaluate("\
480 request.setRequestHeader('Security', 'theater');\nrequest.send();"); 480 request.setRequestHeader('Security', 'theater');\nrequest.send();");
481 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve l); 481 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve l);
482 EXPECT_EQ("", catchLogSystem->lastMessage); 482 EXPECT_EQ("", catchLogSystem->lastMessage);
483 WaitForVariable("result", jsEngine); 483 WaitForVariable("result", jsEngine);
484 EXPECT_FALSE(webRequest->lastRequestHeaders.cend() == 484 EXPECT_FALSE(webRequest->lastRequestHeaders.cend() ==
485 webRequest->lastRequestHeaders.find("Security")); 485 webRequest->lastRequestHeaders.find("Security"));
486 } 486 }
OLDNEW
« no previous file with comments | « test/ReferrerMapping.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld