Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save katsuyoshi/135039 to your computer and use it in GitHub Desktop.
Save katsuyoshi/135039 to your computer and use it in GitHub Desktop.
//
// PLCDocumentViewManagerTest2.m
// ioCoreTest
//
// Created by Katsuyoshi Ito on 09/06/23.
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
//
#import "PLCDocumentViewManagerTest2.h"
#import "UITableViewControllerTestHelper.h"
@implementation PLCDocumentViewManagerTest2
- (void)setUp
{
[super setUp];
[manager showRootView:self];
}
- (NSNumber *)didSetUp
{
return [NSNumber numberWithDouble:0.5];
}
- (void)tearDown
{
[super tearDown];
}
- (void)dealloc
{
[super dealloc];
}
#pragma mark -
#pragma mark Helpers
- (UIViewController *)visibleViewController
{
return manager.navigationController.visibleViewController;
}
- (UITableViewController *)controller
{
return (UITableViewController *)self.visibleViewController;
}
- (UITableView *)tableView
{
return self.controller.tableView;
}
- (void)touchLeftBarButtonItem
{
id target = self.visibleViewController.navigationItem.leftBarButtonItem.target;
if (target) {
[target performSelector:self.visibleViewController.navigationItem.leftBarButtonItem.action];
} else {
[self.visibleViewController.navigationController popViewControllerAnimated:YES];
}
}
- (void)touchRightBarButtonItem
{
id target = self.visibleViewController.navigationItem.rightBarButtonItem.target;
if (target) {
[target performSelector:self.visibleViewController.navigationItem.rightBarButtonItem.action];
} else {
// CHECKME:
}
}
#pragma mark -
#pragma mark Tests
#pragma mark キャンセルボタンで閉じる
- (void)testCloseRootView
{
// キャンセル
[self touchLeftBarButtonItem];
ASSERT(!manager.showing);
}
#pragma mark 編集モードにするが、キャンセルで閉じる
- (void)testEditAndCancel
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAndCancel) afterDelay:0.5];
}
- (void)_test2EditAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// キャンセル
[self touchLeftBarButtonItem];
[self performTest:@selector(_test3EditAndCancel) afterDelay:0.5];
}
- (void)_test3EditAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(!manager.documentViewController.editing);
}
#pragma mark 編集にし、新規セルをタッチでPLC検出ビューを表示し、キャンセルで戻る
- (void)testEditAddNewAndCancel
{
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAddNewAndCancel) afterDelay:0.5];
}
- (void)_test2EditAddNewAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
SELECT_CELL(0, 0);
[self performTest:@selector(_test3EditAddNewAndCancel) afterDelay:0.5];
}
- (void)_test3EditAddNewAndCancel
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
[self touchLeftBarButtonItem];
[self performTest:@selector(_test4EditAddNewAndCancel) afterDelay:0.5];
}
- (void)_test4EditAddNewAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、新規セルをタッチし、手動をタッチでPLC編集ビューを表示し、キャンセルで戻る
- (void)testEditAddNewSelectManuallyAndCancel
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAddNewSelectManuallyAndCancel) afterDelay:0.5];
}
- (void)_test2EditAddNewSelectManuallyAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// PLC追加をタッチ
SELECT_CELL(0, 0);
[self performTest:@selector(_test3EditAddNewSelectManuallyAndCancel) afterDelay:0.5];
}
- (void)_test3EditAddNewSelectManuallyAndCancel
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
// 手動を選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test4EditAddNewSelectManuallyAndCancel) afterDelay:0.5];
}
- (void)_test4EditAddNewSelectManuallyAndCancel
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// 戻をタッチ
[self touchLeftBarButtonItem];
[self performTest:@selector(_test5EditAddNewSelectManuallyAndCancel) afterDelay:0.5];
}
- (void)_test5EditAddNewSelectManuallyAndCancel
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、新規セルをタッチし、手動をタッチでPLC編集ビューを表示し、保存でトップ戻る
- (void)testEditAddNewSelectManuallyAndSave
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAddNewSelectManuallyAndSave) afterDelay:0.5];
}
- (void)_test2EditAddNewSelectManuallyAndSave
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// PLC追加をタッチ
SELECT_CELL(0, 0);
[self performTest:@selector(_test3EditAddNewSelectManuallyAndSave) afterDelay:0.5];
}
- (void)_test3EditAddNewSelectManuallyAndSave
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
// 手動を選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test4EditAddNewSelectManuallyAndSave) afterDelay:0.5];
}
- (void)_test4EditAddNewSelectManuallyAndSave
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// 保存をタッチ
[self touchRightBarButtonItem];
[self performTest:@selector(_test5EditAddNewSelectManuallyAndSave) afterDelay:0.5];
}
- (void)_test5EditAddNewSelectManuallyAndSave
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、新規セルをタッチし、手動をタッチでPLC編集ビューで、PLCをタッチ、メーカー一覧になりキャンセルで戻る
- (void)testEditAddNewSelectManuallySelectPlcAndCancel
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAddNewSelectManuallySelectPlcAndCancel) afterDelay:0.5];
}
- (void)_test2EditAddNewSelectManuallySelectPlcAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// PLC追加をタッチ
SELECT_CELL(0, 0);
[self performTest:@selector(_test3EditAddNewSelectManuallySelectPlcAndCancel) afterDelay:0.5];
}
- (void)_test3EditAddNewSelectManuallySelectPlcAndCancel
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
// 手動を選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test4EditAddNewSelectManuallySelectPlcAndCancel) afterDelay:0.5];
}
- (void)_test4EditAddNewSelectManuallySelectPlcAndCancel
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// PLCを選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test5EditAddNewSelectManuallySelectPlcAndCancel) afterDelay:0.5];
}
- (void)_test5EditAddNewSelectManuallySelectPlcAndCancel
{
ASSERT_EQUAL(manager.makerSelectionViewController, self.visibleViewController);
// 戻をタッチ
[self touchLeftBarButtonItem];
[self performTest:@selector(_test6EditAddNewSelectManuallySelectPlcAndCancel) afterDelay:0.5];
}
- (void)_test6EditAddNewSelectManuallySelectPlcAndCancel
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、新規セルをタッチし、手動をタッチでPLC編集ビューで、PLCをタッチ、メーカー一覧でタッチで機種一覧になりキャンセルで戻る
- (void)testEditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAddNewSelectManuallySelectPlcSelectMakerAndCancel) afterDelay:0.5];
}
- (void)_test2EditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// PLC追加をタッチ
SELECT_CELL(0, 0);
[self performTest:@selector(_test3EditAddNewSelectManuallySelectPlcSelectMakerAndCancel) afterDelay:0.5];
}
- (void)_test3EditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
// 手動を選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test4EditAddNewSelectManuallySelectPlcSelectMakerAndCancel) afterDelay:0.5];
}
- (void)_test4EditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// PLCを選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test5EditAddNewSelectManuallySelectPlcSelectMakerAndCancel) afterDelay:0.5];
}
- (void)_test5EditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
ASSERT_EQUAL(manager.makerSelectionViewController, self.visibleViewController);
// メーカーを選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test6EditAddNewSelectManuallySelectPlcSelectMakerAndCancel) afterDelay:0.5];
}
- (void)_test6EditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
ASSERT_EQUAL(manager.typeSelectionViewController, self.visibleViewController);
// 戻をタッチ
[self touchLeftBarButtonItem];
[self performTest:@selector(_test7EditAddNewSelectManuallySelectPlcSelectMakerAndCancel) afterDelay:0.5];
}
- (void)_test7EditAddNewSelectManuallySelectPlcSelectMakerAndCancel
{
ASSERT_EQUAL(manager.makerSelectionViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、新規セルをタッチし、手動をタッチでPLC編集ビューで、PLCをタッチ、メーカー一覧でタッチで機種一覧になり機種選択で、PLC編集ビューに戻る
- (void)testEditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditAddNewSelectManuallySelectPlcSelectMakerSelectType) afterDelay:0.5];
}
- (void)_test2EditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// PLC追加をタッチ
SELECT_CELL(0, 0);
[self performTest:@selector(_test3EditAddNewSelectManuallySelectPlcSelectMakerSelectType) afterDelay:0.5];
}
- (void)_test3EditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
ASSERT_EQUAL(manager.detectViewController, self.visibleViewController);
// 手動を選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test4EditAddNewSelectManuallySelectPlcSelectMakerSelectType) afterDelay:0.5];
}
- (void)_test4EditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// PLCを選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test5EditAddNewSelectManuallySelectPlcSelectMakerSelectType) afterDelay:0.5];
}
- (void)_test5EditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
ASSERT_EQUAL(manager.makerSelectionViewController, self.visibleViewController);
// メーカーを選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test6EditAddNewSelectManuallySelectPlcSelectMakerSelectType) afterDelay:0.5];
}
- (void)_test6EditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
ASSERT_EQUAL(manager.typeSelectionViewController, self.visibleViewController);
// 機種を選択
SELECT_CELL(0, 0);
[self performTest:@selector(_test7EditAddNewSelectManuallySelectPlcSelectMakerSelectType) afterDelay:0.5];
}
- (void)_test7EditAddNewSelectManuallySelectPlcSelectMakerSelectType
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、既存のセルをタッチでPLC編集ビューを表示し、キャンセルで戻る
- (void)testEditSelectCellAndCancel
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditSelectCellAndCancel) afterDelay:0.5];
}
- (void)_test2EditSelectCellAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// 既存のPLCタッチ
SELECT_CELL(0, 1);
[self performTest:@selector(_test3EditSelectCellAndCancel) afterDelay:0.5];
}
- (void)_test3EditSelectCellAndCancel
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// 戻をタッチ
[self touchLeftBarButtonItem];
[self performTest:@selector(_test4EditSelectCellAndCancel) afterDelay:0.5];
}
- (void)_test4EditSelectCellAndCancel
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、既存のセルをタッチでPLC編集ビューを表示し、保存で戻る
- (void)testEditSelectCellAndSave
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditSelectCellAndSave) afterDelay:0.5];
}
- (void)_test2EditSelectCellAndSave
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// 既存のPLCタッチ
SELECT_CELL(0, 1);
[self performTest:@selector(_test3EditSelectCellAndSave) afterDelay:0.5];
}
- (void)_test3EditSelectCellAndSave
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// 保存をタッチ
[self touchRightBarButtonItem];
[self performTest:@selector(_test4EditSelectCellAndSave) afterDelay:0.5];
}
- (void)_test4EditSelectCellAndSave
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark 編集にし、既存のセルをタッチでPLC編集ビューを表示し、PLCをタッチするが編集不可なので移動しない
- (void)testEditSelectCellAndSelectPlc
{
// 編集
[self touchRightBarButtonItem];
[self performTest:@selector(_test2EditSelectCellAndSelectPlc) afterDelay:0.5];
}
- (void)_test2EditSelectCellAndSelectPlc
{
ASSERT_EQUAL(manager.documentViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
// 既存のPLCタッチ
SELECT_CELL(0, 1);
[self performTest:@selector(_test3EditSelectCellAndSelectPlc) afterDelay:0.5];
}
- (void)_test3EditSelectCellAndSelectPlc
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
// PLCタッチ
SELECT_CELL(0, 0);
[self performTest:@selector(_test4EditSelectCellAndSelectPlc) afterDelay:0.5];
}
- (void)_test4EditSelectCellAndSelectPlc
{
ASSERT_EQUAL(manager.editViewController, self.visibleViewController);
ASSERT(manager.documentViewController.editing);
}
#pragma mark -
#pragma mark Option
// Uncomment it, if you want to test this class except other passed test classes.
//#define TESTS_ALWAYS
#ifdef TESTS_ALWAYS
- (void)testThisClassAlways { ASSERT_FAIL(@"fail always"); }
+ (BOOL)forceTestsAnyway { return YES; }
#endif
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment