Browse Source

testable timer

works_for_me
Volker Birk 2 years ago
parent
commit
c9c3cb3c54
3 changed files with 4 additions and 4 deletions
  1. +1
    -1
      pEpMacOSAdapter/pEpUpdater.h
  2. +1
    -2
      pEpMacOSAdapter/pEpUpdater.mm
  3. +2
    -1
      pEpUpdater Test/pEpUpdater_Test.m

+ 1
- 1
pEpMacOSAdapter/pEpUpdater.h View File

@ -14,7 +14,7 @@
@interface pEpUpdater : NSObject
/// default 2 hours = 7200 seconds
@property double cycle;
@property NSTimer* timer;
/// path with config files
@property NSString* configPath;


+ 1
- 2
pEpMacOSAdapter/pEpUpdater.mm View File

@ -21,7 +21,6 @@ DownloadNotification _subscriber = nil;
- (id)initWithSubscriber:(DownloadNotification)subscriber
{
self = [super init];
self.cycle = CYCLE;
self.configPath = @"/Library/Application Support/pEp/Updater";
_subscriber = subscriber;
return self;
@ -34,7 +33,7 @@ DownloadNotification _subscriber = nil;
- (void)scheduleUpdates
{
[NSTimer scheduledTimerWithTimeInterval:self.cycle target:self selector:@selector(updateAll:) userInfo:nil repeats:YES];
self.timer = [NSTimer scheduledTimerWithTimeInterval:CYCLE target:self selector:@selector(updateAll:) userInfo:nil repeats:YES];
}
- (void)updateAll:(NSTimer*)timer


+ 2
- 1
pEpUpdater Test/pEpUpdater_Test.m View File

@ -49,7 +49,8 @@ XCTestExpectation* downloadingExpectation;
XCTWaiter* waiter = [XCTWaiter new];
waiter.delegate = self;
[updater scheduleUpdates];
[waiter waitForExpectations:@[downloadingExpectation] timeout:5];
[updater.timer fire]; // don't wait 2 hours now
[waiter waitForExpectations:@[downloadingExpectation] timeout:30];
}
/*


Loading…
Cancel
Save