-
Notifications
You must be signed in to change notification settings - Fork 27
/
PanelDataObserversTests.swift
39 lines (32 loc) · 1.46 KB
/
PanelDataObserversTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Foundation
import Shared
import XCTest
@testable import Client
private class MockDataObserverDelegate: DataObserverDelegate {
var didInvalidateCount = 0
var willInvalidateCount = 0
func didInvalidateDataSources(forceHighlights highlights: Bool, forceTopSites topSites: Bool) {
didInvalidateCount += 1
}
func willInvalidateDataSources(forceHighlights highlights: Bool, forceTopSites topSites: Bool) {
willInvalidateCount += 1
}
}
class PanelDataObserversTests: XCTestCase {
func testActivityStreamDelegates() {
let profile = MockProfile()
let observer = ActivityStreamDataObserver(profile: profile)
let delegate = MockDataObserverDelegate()
observer.delegate = delegate
NotificationCenter.default.post(name: NotificationFirefoxAccountChanged,
object: nil)
NotificationCenter.default.post(name: NotificationProfileDidFinishSyncing,
object: nil)
NotificationCenter.default.post(name: NotificationPrivateDataClearedHistory,
object: nil)
waitForCondition(timeout: 5) { delegate.didInvalidateCount == 3 && delegate.willInvalidateCount == 3 }
}
}