-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from odigeoteam/develop
ActioBarManager Callbacks
- Loading branch information
Showing
6 changed files
with
108 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// ActionBarManagerTests.swift | ||
// ActionBarManagerTests | ||
// | ||
// Created by Nelson Dominguez Leon on 13/09/16. | ||
// Copyright © 2016 ODIGEO. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import ActionBarManager | ||
|
||
class ActionBarObserver: ActionBarDelegate { | ||
|
||
var doneButtonPressed: Bool? | ||
var directionButtonPressed: Direction? | ||
|
||
func doneButtonPressed(actionBar: ActionBar, barButtonItem: UIBarButtonItem) { | ||
doneButtonPressed = true | ||
} | ||
|
||
func directionButtonPressed(actionBar: ActionBar, direction: Direction) { | ||
directionButtonPressed = direction | ||
} | ||
} | ||
|
||
class ActionBarTests: XCTestCase { | ||
|
||
var delegate: ActionBarObserver! | ||
var actionbar: ActionBar! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
delegate = ActionBarObserver() | ||
actionbar = ActionBar(delegate: delegate) | ||
} | ||
|
||
override func tearDown() { | ||
|
||
delegate = nil | ||
actionbar = nil | ||
|
||
super.tearDown() | ||
} | ||
|
||
func testActionBarPrevious() { | ||
|
||
let previous = actionbar.items?.first | ||
XCTAssertNotNil(previous) | ||
|
||
actionbar.previousHandler(sender: previous!) | ||
|
||
XCTAssertNotNil(delegate.directionButtonPressed) | ||
XCTAssert(delegate.directionButtonPressed! == .previous) | ||
} | ||
|
||
func testActionBarNext() { | ||
|
||
let next = actionbar.items?[2] | ||
XCTAssertNotNil(next) | ||
|
||
actionbar.nextHandler(sender: next!) | ||
|
||
XCTAssertNotNil(delegate.directionButtonPressed) | ||
XCTAssert(delegate.directionButtonPressed! == .next) | ||
} | ||
|
||
func testActionBarDone() { | ||
|
||
let done = actionbar.items?.last | ||
XCTAssertNotNil(done) | ||
|
||
actionbar.handleActionBarDone(item: done!) | ||
|
||
XCTAssertNotNil(delegate.doneButtonPressed) | ||
XCTAssert(delegate.doneButtonPressed! == true) | ||
} | ||
} |