Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 ASSERT_TRUE(filterEngine->IsFirstRun()); | 374 ASSERT_TRUE(filterEngine->IsFirstRun()); |
375 } | 375 } |
376 | 376 |
377 TEST_F(FilterEngineTest, SetRemoveFilterChangeCallback) | 377 TEST_F(FilterEngineTest, SetRemoveFilterChangeCallback) |
378 { | 378 { |
379 int timesCalled = 0; | 379 int timesCalled = 0; |
380 MockFilterChangeCallback mockFilterChangeCallback(timesCalled); | 380 MockFilterChangeCallback mockFilterChangeCallback(timesCalled); |
381 | 381 |
382 filterEngine->SetFilterChangeCallback(mockFilterChangeCallback); | 382 filterEngine->SetFilterChangeCallback(mockFilterChangeCallback); |
383 filterEngine->GetFilter("foo")->AddToList(); | 383 filterEngine->GetFilter("foo")->AddToList(); |
384 ASSERT_EQ(2, timesCalled); | 384 EXPECT_EQ(2, timesCalled); |
sergei
2015/08/06 08:09:37
Nit: it could be a good practice to use EXPECT_* w
sergei
2015/08/06 08:09:37
It would be also good to test when timesCalled is
Felix Dahlke
2015/08/13 14:17:50
Hm, you're right, I think I should use it more oft
Felix Dahlke
2015/08/13 14:17:50
That's not really possible - it's called two times
| |
385 | 385 |
386 filterEngine->RemoveFilterChangeCallback(); | 386 filterEngine->RemoveFilterChangeCallback(); |
387 filterEngine->GetFilter("foo")->RemoveFromList(); | 387 filterEngine->GetFilter("foo")->RemoveFromList(); |
388 ASSERT_EQ(2, timesCalled); | 388 EXPECT_EQ(2, timesCalled); |
389 } | 389 } |
390 | 390 |
391 TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback) | 391 TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback) |
392 { | 392 { |
393 mockWebRequest->response.status = 0; | 393 mockWebRequest->response.status = 0; |
394 mockWebRequest->response.responseStatus = 200; | 394 mockWebRequest->response.responseStatus = 200; |
395 mockWebRequest->response.responseText = "\ | 395 mockWebRequest->response.responseText = "\ |
396 {\ | 396 {\ |
397 \"test\": {\ | 397 \"test\": {\ |
398 \"version\": \"1.0.2\",\ | 398 \"version\": \"1.0.2\",\ |
399 \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\ | 399 \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\ |
400 }\ | 400 }\ |
401 }"; | 401 }"; |
402 | 402 |
403 int timesCalled = 0; | 403 int timesCalled = 0; |
404 MockUpdateAvailableCallback mockUpdateAvailableCallback(timesCalled); | 404 MockUpdateAvailableCallback mockUpdateAvailableCallback(timesCalled); |
405 | 405 |
406 filterEngine->SetUpdateAvailableCallback(mockUpdateAvailableCallback); | 406 filterEngine->SetUpdateAvailableCallback(mockUpdateAvailableCallback); |
407 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); | 407 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); |
408 AdblockPlus::Sleep(100); | 408 AdblockPlus::Sleep(100); |
409 ASSERT_EQ(1, timesCalled); | 409 ASSERT_EQ(1, timesCalled); |
410 | 410 |
411 filterEngine->RemoveUpdateAvailableCallback(); | 411 filterEngine->RemoveUpdateAvailableCallback(); |
412 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); | 412 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); |
413 AdblockPlus::Sleep(100); | 413 AdblockPlus::Sleep(100); |
414 ASSERT_EQ(1, timesCalled); | 414 ASSERT_EQ(1, timesCalled); |
415 } | 415 } |
LEFT | RIGHT |