| 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-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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 appInfo.name = "1"; | 107 appInfo.name = "1"; |
| 108 appInfo.version = "3"; | 108 appInfo.version = "3"; |
| 109 appInfo.application = "4"; | 109 appInfo.application = "4"; |
| 110 appInfo.applicationVersion = "2"; | 110 appInfo.applicationVersion = "2"; |
| 111 appInfo.developmentBuild = false; | 111 appInfo.developmentBuild = false; |
| 112 | 112 |
| 113 Reset(); | 113 Reset(); |
| 114 ForceUpdateCheck(); | 114 ForceUpdateCheck(); |
| 115 | 115 |
| 116 AdblockPlus::Sleep(100); | 116 std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 117 | 117 |
| 118 ASSERT_FALSE(eventCallbackCalled); | 118 ASSERT_FALSE(eventCallbackCalled); |
| 119 ASSERT_TRUE(updateCallbackCalled); | 119 ASSERT_TRUE(updateCallbackCalled); |
| 120 ASSERT_FALSE(updateError.empty()); | 120 ASSERT_FALSE(updateError.empty()); |
| 121 | 121 |
| 122 std::string expectedUrl(filterEngine->GetPref("update_url_release")->AsString(
)); | 122 std::string expectedUrl(filterEngine->GetPref("update_url_release")->AsString(
)); |
| 123 std::string platform = jsEngine->Evaluate("require('info').platform")->AsStrin
g(); | 123 std::string platform = jsEngine->Evaluate("require('info').platform")->AsStrin
g(); |
| 124 std::string platformVersion = jsEngine->Evaluate("require('info').platformVers
ion")->AsString(); | 124 std::string platformVersion = jsEngine->Evaluate("require('info').platformVers
ion")->AsString(); |
| 125 | 125 |
| 126 FindAndReplace(expectedUrl, "%NAME%", appInfo.name); | 126 FindAndReplace(expectedUrl, "%NAME%", appInfo.name); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 143 | 143 |
| 144 appInfo.name = "1"; | 144 appInfo.name = "1"; |
| 145 appInfo.version = "3"; | 145 appInfo.version = "3"; |
| 146 appInfo.application = "4"; | 146 appInfo.application = "4"; |
| 147 appInfo.applicationVersion = "2"; | 147 appInfo.applicationVersion = "2"; |
| 148 appInfo.developmentBuild = true; | 148 appInfo.developmentBuild = true; |
| 149 | 149 |
| 150 Reset(); | 150 Reset(); |
| 151 ForceUpdateCheck(); | 151 ForceUpdateCheck(); |
| 152 | 152 |
| 153 AdblockPlus::Sleep(100); | 153 std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 154 | 154 |
| 155 ASSERT_TRUE(eventCallbackCalled); | 155 ASSERT_TRUE(eventCallbackCalled); |
| 156 ASSERT_EQ(1u, eventCallbackParams.size()); | 156 ASSERT_EQ(1u, eventCallbackParams.size()); |
| 157 ASSERT_EQ("https://foo.bar/", eventCallbackParams[0]->AsString()); | 157 ASSERT_EQ("https://foo.bar/", eventCallbackParams[0]->AsString()); |
| 158 ASSERT_TRUE(updateCallbackCalled); | 158 ASSERT_TRUE(updateCallbackCalled); |
| 159 ASSERT_TRUE(updateError.empty()); | 159 ASSERT_TRUE(updateError.empty()); |
| 160 | 160 |
| 161 std::string expectedUrl(filterEngine->GetPref("update_url_devbuild")->AsString
()); | 161 std::string expectedUrl(filterEngine->GetPref("update_url_devbuild")->AsString
()); |
| 162 std::string platform = jsEngine->Evaluate("require('info').platform")->AsStrin
g(); | 162 std::string platform = jsEngine->Evaluate("require('info').platform")->AsStrin
g(); |
| 163 std::string platformVersion = jsEngine->Evaluate("require('info').platformVers
ion")->AsString(); | 163 std::string platformVersion = jsEngine->Evaluate("require('info').platformVers
ion")->AsString(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 182 | 182 |
| 183 appInfo.name = "1"; | 183 appInfo.name = "1"; |
| 184 appInfo.version = "3"; | 184 appInfo.version = "3"; |
| 185 appInfo.application = "4"; | 185 appInfo.application = "4"; |
| 186 appInfo.applicationVersion = "2"; | 186 appInfo.applicationVersion = "2"; |
| 187 appInfo.developmentBuild = true; | 187 appInfo.developmentBuild = true; |
| 188 | 188 |
| 189 Reset(); | 189 Reset(); |
| 190 ForceUpdateCheck(); | 190 ForceUpdateCheck(); |
| 191 | 191 |
| 192 AdblockPlus::Sleep(100); | 192 std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 193 | 193 |
| 194 ASSERT_TRUE(eventCallbackCalled); | 194 ASSERT_TRUE(eventCallbackCalled); |
| 195 ASSERT_EQ(1u, eventCallbackParams.size()); | 195 ASSERT_EQ(1u, eventCallbackParams.size()); |
| 196 ASSERT_EQ("https://foo.bar/", eventCallbackParams[0]->AsString()); | 196 ASSERT_EQ("https://foo.bar/", eventCallbackParams[0]->AsString()); |
| 197 ASSERT_TRUE(updateCallbackCalled); | 197 ASSERT_TRUE(updateCallbackCalled); |
| 198 ASSERT_TRUE(updateError.empty()); | 198 ASSERT_TRUE(updateError.empty()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TEST_F(UpdateCheckTest, WrongApplication) | 201 TEST_F(UpdateCheckTest, WrongApplication) |
| 202 { | 202 { |
| 203 webRequest->response.status = AdblockPlus::WebRequest::NS_OK; | 203 webRequest->response.status = AdblockPlus::WebRequest::NS_OK; |
| 204 webRequest->response.responseStatus = 200; | 204 webRequest->response.responseStatus = 200; |
| 205 webRequest->response.responseText = "{\"1/3\": {\"version\":\"3.1\",\"url\":\"
https://foo.bar/\"}}"; | 205 webRequest->response.responseText = "{\"1/3\": {\"version\":\"3.1\",\"url\":\"
https://foo.bar/\"}}"; |
| 206 | 206 |
| 207 appInfo.name = "1"; | 207 appInfo.name = "1"; |
| 208 appInfo.version = "3"; | 208 appInfo.version = "3"; |
| 209 appInfo.application = "4"; | 209 appInfo.application = "4"; |
| 210 appInfo.applicationVersion = "2"; | 210 appInfo.applicationVersion = "2"; |
| 211 appInfo.developmentBuild = true; | 211 appInfo.developmentBuild = true; |
| 212 | 212 |
| 213 Reset(); | 213 Reset(); |
| 214 ForceUpdateCheck(); | 214 ForceUpdateCheck(); |
| 215 | 215 |
| 216 AdblockPlus::Sleep(100); | 216 std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 217 | 217 |
| 218 ASSERT_FALSE(eventCallbackCalled); | 218 ASSERT_FALSE(eventCallbackCalled); |
| 219 ASSERT_TRUE(updateCallbackCalled); | 219 ASSERT_TRUE(updateCallbackCalled); |
| 220 ASSERT_TRUE(updateError.empty()); | 220 ASSERT_TRUE(updateError.empty()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST_F(UpdateCheckTest, WrongVersion) | 223 TEST_F(UpdateCheckTest, WrongVersion) |
| 224 { | 224 { |
| 225 webRequest->response.status = AdblockPlus::WebRequest::NS_OK; | 225 webRequest->response.status = AdblockPlus::WebRequest::NS_OK; |
| 226 webRequest->response.responseStatus = 200; | 226 webRequest->response.responseStatus = 200; |
| 227 webRequest->response.responseText = "{\"1\": {\"version\":\"3\",\"url\":\"http
s://foo.bar/\"}}"; | 227 webRequest->response.responseText = "{\"1\": {\"version\":\"3\",\"url\":\"http
s://foo.bar/\"}}"; |
| 228 | 228 |
| 229 appInfo.name = "1"; | 229 appInfo.name = "1"; |
| 230 appInfo.version = "3"; | 230 appInfo.version = "3"; |
| 231 appInfo.application = "4"; | 231 appInfo.application = "4"; |
| 232 appInfo.applicationVersion = "2"; | 232 appInfo.applicationVersion = "2"; |
| 233 appInfo.developmentBuild = true; | 233 appInfo.developmentBuild = true; |
| 234 | 234 |
| 235 Reset(); | 235 Reset(); |
| 236 ForceUpdateCheck(); | 236 ForceUpdateCheck(); |
| 237 | 237 |
| 238 AdblockPlus::Sleep(100); | 238 std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 239 | 239 |
| 240 ASSERT_FALSE(eventCallbackCalled); | 240 ASSERT_FALSE(eventCallbackCalled); |
| 241 ASSERT_TRUE(updateCallbackCalled); | 241 ASSERT_TRUE(updateCallbackCalled); |
| 242 ASSERT_TRUE(updateError.empty()); | 242 ASSERT_TRUE(updateError.empty()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 TEST_F(UpdateCheckTest, WrongURL) | 245 TEST_F(UpdateCheckTest, WrongURL) |
| 246 { | 246 { |
| 247 webRequest->response.status = AdblockPlus::WebRequest::NS_OK; | 247 webRequest->response.status = AdblockPlus::WebRequest::NS_OK; |
| 248 webRequest->response.responseStatus = 200; | 248 webRequest->response.responseStatus = 200; |
| 249 webRequest->response.responseText = "{\"1\": {\"version\":\"3.1\",\"url\":\"ht
tp://insecure/\"}}"; | 249 webRequest->response.responseText = "{\"1\": {\"version\":\"3.1\",\"url\":\"ht
tp://insecure/\"}}"; |
| 250 | 250 |
| 251 appInfo.name = "1"; | 251 appInfo.name = "1"; |
| 252 appInfo.version = "3"; | 252 appInfo.version = "3"; |
| 253 appInfo.application = "4"; | 253 appInfo.application = "4"; |
| 254 appInfo.applicationVersion = "2"; | 254 appInfo.applicationVersion = "2"; |
| 255 appInfo.developmentBuild = true; | 255 appInfo.developmentBuild = true; |
| 256 | 256 |
| 257 Reset(); | 257 Reset(); |
| 258 ForceUpdateCheck(); | 258 ForceUpdateCheck(); |
| 259 | 259 |
| 260 AdblockPlus::Sleep(100); | 260 std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 261 | 261 |
| 262 ASSERT_FALSE(eventCallbackCalled); | 262 ASSERT_FALSE(eventCallbackCalled); |
| 263 ASSERT_TRUE(updateCallbackCalled); | 263 ASSERT_TRUE(updateCallbackCalled); |
| 264 ASSERT_FALSE(updateError.empty()); | 264 ASSERT_FALSE(updateError.empty()); |
| 265 } | 265 } |
| OLD | NEW |