Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/FilterEngine.cpp

Issue 4756164013195264: Issue 1376 - Add tests for SetFilterChangeCallback (Closed)
Left Patch Set: Rebased, use GetFilter() Created May 29, 2015, 11:05 p.m.
Right Patch Set: Rebased, use EXPECT instead of ASSERT Created Aug. 13, 2015, 4:52 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « dependencies ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 }
LEFTRIGHT
« dependencies ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld