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

Side by Side Diff: test/WebRequest.cpp

Issue 29433591: Issue 5180 - start to inject implementation of WebRequest into JsEngine::ctr (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created May 8, 2017, 11:59 a.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/UpdateCheck.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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 return std::make_pair(false, std::set<std::string>()); 71 return std::make_pair(false, std::set<std::string>());
72 } 72 }
73 73
74 // mutable. Very Ugly. But we are testing and need to change this in GET whi ch is const. 74 // mutable. Very Ugly. But we are testing and need to change this in GET whi ch is const.
75 mutable std::mutex requestHeaderNamesMutex; 75 mutable std::mutex requestHeaderNamesMutex;
76 mutable std::map<std::string, std::set<std::string>> requestHeaderNames; 76 mutable std::map<std::string, std::set<std::string>> requestHeaderNames;
77 }; 77 };
78 78
79 template<class T> 79 template<class T>
80 class WebRequestTest : public BaseJsTest 80 class WebRequestTest : public ::testing::Test
81 { 81 {
82 protected: 82 protected:
83 void SetUp() 83 void SetUp()
84 { 84 {
85 BaseJsTest::SetUp(); 85 JsEngineCreationParameters jsEngineParams;
86 jsEngineParams.timer.reset(new NoopTimer());
87 jsEngineParams.fileSystem.reset(new LazyFileSystem());
88 jsEngine = CreateJsEngine(std::move(jsEngineParams));
86 webRequest = std::make_shared<T>(); 89 webRequest = std::make_shared<T>();
87 jsEngine->SetWebRequest(webRequest); 90 jsEngine->SetWebRequest(webRequest);
88 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem()));
89 } 91 }
90 92
91 std::shared_ptr<T> webRequest; 93 std::shared_ptr<T> webRequest;
94 JsEnginePtr jsEngine;
92 }; 95 };
93 96
94 typedef WebRequestTest<MockWebRequest> MockWebRequestTest; 97 typedef WebRequestTest<MockWebRequest> MockWebRequestTest;
95 typedef WebRequestTest<AdblockPlus::DefaultWebRequestSync> DefaultWebRequestTe st; 98 typedef WebRequestTest<AdblockPlus::DefaultWebRequestSync> DefaultWebRequestTe st;
96 typedef WebRequestTest<MockWebRequest> XMLHttpRequestTest; 99 typedef WebRequestTest<MockWebRequest> XMLHttpRequestTest;
97 100
98 // we return the url of the XHR. 101 // we return the url of the XHR.
99 std::string ResetTestXHR(const AdblockPlus::JsEnginePtr& jsEngine, const std:: string& defaultUrl = "") 102 std::string ResetTestXHR(const AdblockPlus::JsEnginePtr& jsEngine, const std:: string& defaultUrl = "")
100 { 103 {
101 std::string url = defaultUrl; 104 std::string url = defaultUrl;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve l); 343 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve l);
341 EXPECT_EQ("", catchLogSystem->lastMessage); 344 EXPECT_EQ("", catchLogSystem->lastMessage);
342 WaitForVariable("result", jsEngine); 345 WaitForVariable("result", jsEngine);
343 { 346 {
344 auto headersRequest = webRequest->headersForRequest(url); 347 auto headersRequest = webRequest->headersForRequest(url);
345 EXPECT_TRUE(headersRequest.first); 348 EXPECT_TRUE(headersRequest.first);
346 const auto& headers = headersRequest.second; 349 const auto& headers = headersRequest.second;
347 EXPECT_FALSE(headers.cend() == headers.find("Security")); 350 EXPECT_FALSE(headers.cend() == headers.find("Security"));
348 } 351 }
349 } 352 }
OLDNEW
« no previous file with comments | « test/UpdateCheck.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld