| OLD | NEW |
| 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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #ifndef MOCKS_H | 18 #ifndef MOCKS_H |
| 19 #define MOCKS_H | 19 #define MOCKS_H |
| 20 | 20 |
| 21 #include <AdblockPlus.h> | 21 #include <AdblockPlus.h> |
| 22 #include <gtest/gtest.h> | 22 #include <gtest/gtest.h> |
| 23 #include "../src/Thread.h" | 23 #include "../src/Thread.h" |
| 24 | 24 |
| 25 class ThrowingErrorCallback : public AdblockPlus::ErrorCallback | 25 class ThrowingLogSystem : public AdblockPlus::LogSystem |
| 26 { | 26 { |
| 27 public: | 27 public: |
| 28 void operator()(const std::string& message) | 28 void operator()(LogLevel logLevel, const std::string& message, |
| 29 const std::string& source) |
| 29 { | 30 { |
| 30 throw std::runtime_error("Unexpected error: " + message); | 31 throw std::runtime_error("Unexpected error: " + message); |
| 31 } | 32 } |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 class ThrowingFileSystem : public AdblockPlus::FileSystem | 35 class ThrowingFileSystem : public AdblockPlus::FileSystem |
| 35 { | 36 { |
| 36 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const | 37 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const |
| 37 { | 38 { |
| 38 throw std::runtime_error("Not implemented"); | 39 throw std::runtime_error("Not implemented"); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 | 129 |
| 129 class BaseJsTest : public ::testing::Test | 130 class BaseJsTest : public ::testing::Test |
| 130 { | 131 { |
| 131 protected: | 132 protected: |
| 132 AdblockPlus::JsEnginePtr jsEngine; | 133 AdblockPlus::JsEnginePtr jsEngine; |
| 133 | 134 |
| 134 virtual void SetUp() | 135 virtual void SetUp() |
| 135 { | 136 { |
| 136 jsEngine = AdblockPlus::JsEngine::New(); | 137 jsEngine = AdblockPlus::JsEngine::New(); |
| 137 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new ThrowingErrorCa
llback)); | 138 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); |
| 138 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); | 139 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); |
| 139 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); | 140 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); |
| 140 } | 141 } |
| 141 }; | 142 }; |
| 142 | 143 |
| 143 #endif | 144 #endif |
| OLD | NEW |