| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 throw std::runtime_error("Not implemented"); | 60 throw std::runtime_error("Not implemented"); |
| 61 } | 61 } |
| 62 | 62 |
| 63 std::string Resolve(const std::string& path) const | 63 std::string Resolve(const std::string& path) const |
| 64 { | 64 { |
| 65 throw std::runtime_error("Not implemented"); | 65 throw std::runtime_error("Not implemented"); |
| 66 } | 66 } |
| 67 | 67 |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 class ThrowingWebRequest : public AdblockPlus::WebRequest | 70 class ThrowingWebRequest : public AdblockPlus::IWebRequest, public AdblockPlus::
WebRequest |
| 71 { | 71 { |
| 72 public: | 72 public: |
| 73 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const | 73 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const override |
| 74 { | 74 { |
| 75 throw std::runtime_error("Unexpected GET: " + url); | 75 throw std::runtime_error("Unexpected GET: " + url); |
| 76 } | 76 } |
| 77 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders
, const GetCallback&) override |
| 78 { |
| 79 throw std::runtime_error("Unexpected GET: " + url); |
| 80 } |
| 77 }; | 81 }; |
| 78 | 82 |
| 79 class LazyFileSystem : public AdblockPlus::FileSystem | 83 class LazyFileSystem : public AdblockPlus::FileSystem |
| 80 { | 84 { |
| 81 public: | 85 public: |
| 82 std::shared_ptr<std::istream> Read(const std::string& path) const | 86 std::shared_ptr<std::istream> Read(const std::string& path) const |
| 83 { | 87 { |
| 84 std::string dummyData(""); | 88 std::string dummyData(""); |
| 85 if (path == "patterns.ini") | 89 if (path == "patterns.ini") |
| 86 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; | 90 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 135 |
| 132 class LazyLogSystem : public AdblockPlus::LogSystem | 136 class LazyLogSystem : public AdblockPlus::LogSystem |
| 133 { | 137 { |
| 134 public: | 138 public: |
| 135 void operator()(LogLevel logLevel, const std::string& message, | 139 void operator()(LogLevel logLevel, const std::string& message, |
| 136 const std::string& source) | 140 const std::string& source) |
| 137 { | 141 { |
| 138 } | 142 } |
| 139 }; | 143 }; |
| 140 | 144 |
| 141 AdblockPlus::JsEnginePtr CreateJsEngine(const AdblockPlus::AppInfo& appInfo = Ad
blockPlus::AppInfo()); | 145 AdblockPlus::JsEnginePtr CreateJsEngine(const AdblockPlus::AppInfo& appInfo = Ad
blockPlus::AppInfo(), |
| 146 AdblockPlus::WebRequestPtr webRequest = AdblockPlus::WebRequestPtr(new Throwin
gWebRequest())); |
| 142 | 147 |
| 143 class BaseJsTest : public ::testing::Test | 148 class BaseJsTest : public ::testing::Test |
| 144 { | 149 { |
| 145 protected: | 150 protected: |
| 146 AdblockPlus::JsEnginePtr jsEngine; | 151 AdblockPlus::JsEnginePtr jsEngine; |
| 147 | 152 |
| 148 virtual void SetUp() | 153 virtual void SetUp() |
| 149 { | 154 { |
| 150 jsEngine = CreateJsEngine(); | 155 jsEngine = CreateJsEngine(); |
| 151 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); | 156 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); |
| 152 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); | 157 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); |
| 153 jsEngine->SetWebRequest(std::make_shared<ThrowingWebRequest>()); | 158 jsEngine->SetWebRequest(std::make_shared<ThrowingWebRequest>()); |
| 154 } | 159 } |
| 155 }; | 160 }; |
| 156 | 161 |
| 157 #endif | 162 #endif |
| OLD | NEW |