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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ASSERT_ANY_THROW(jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr())); | 170 ASSERT_ANY_THROW(jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr())); |
171 AdblockPlus::LogSystemPtr logSystem(new AdblockPlus::DefaultLogSystem()); | 171 AdblockPlus::LogSystemPtr logSystem(new AdblockPlus::DefaultLogSystem()); |
172 jsEngine->SetLogSystem(logSystem); | 172 jsEngine->SetLogSystem(logSystem); |
173 ASSERT_EQ(logSystem, jsEngine->GetLogSystem()); | 173 ASSERT_EQ(logSystem, jsEngine->GetLogSystem()); |
174 | 174 |
175 ASSERT_TRUE(jsEngine->GetFileSystem()); | 175 ASSERT_TRUE(jsEngine->GetFileSystem()); |
176 ASSERT_ANY_THROW(jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr())); | 176 ASSERT_ANY_THROW(jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr())); |
177 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); | 177 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); |
178 jsEngine->SetFileSystem(fileSystem); | 178 jsEngine->SetFileSystem(fileSystem); |
179 ASSERT_EQ(fileSystem, jsEngine->GetFileSystem()); | 179 ASSERT_EQ(fileSystem, jsEngine->GetFileSystem()); |
180 | |
181 ASSERT_TRUE(jsEngine->GetWebRequest()); | |
182 ASSERT_ANY_THROW(jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr())); | |
183 AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest()); | |
184 jsEngine->SetWebRequest(webRequest); | |
185 ASSERT_EQ(webRequest, jsEngine->GetWebRequest()); | |
186 } | 180 } |
187 | 181 |
188 TEST(NewJsEngineTest, GlobalPropertyTest) | 182 TEST(NewJsEngineTest, GlobalPropertyTest) |
189 { | 183 { |
190 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); | 184 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
191 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); | 185 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); |
192 auto foo = jsEngine->Evaluate("foo"); | 186 auto foo = jsEngine->Evaluate("foo"); |
193 ASSERT_TRUE(foo.IsString()); | 187 ASSERT_TRUE(foo.IsString()); |
194 ASSERT_EQ(foo.AsString(), "bar"); | 188 ASSERT_EQ(foo.AsString(), "bar"); |
195 } | 189 } |
196 | 190 |
OLD | NEW |