Revision control

/* 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 */
import Foundation
@testable import Client
import WebKit
import XCTest
class TabEventHandlerTests: XCTestCase {
func testEventDelivery() {
let tab = Tab(bvc: BrowserViewController.foregroundBVC(), configuration: WKWebViewConfiguration())
let handler = DummyHandler()
XCTAssertNil(handler.isFocused), for: tab)
XCTAssertTrue(handler.isFocused!), for: tab)
class DummyHandler: TabEventHandler {
// This is not how this should be written in production — the handler shouldn't be keeping track
// of individual tab state.
var isFocused: Bool? = nil
init() {
register(self, forTabEvents: .didGainFocus, .didLoseFocus)
func tabDidGainFocus(_ tab: Tab) {
isFocused = true
func tabDidLoseFocus(_ tab: Tab) {
isFocused = false