测试UI的快捷入口
来源:互联网 发布:解剖学软件哪个好 编辑:程序博客网 时间:2024/06/05 03:40
这个视图控制器以tableView的形势列出想要测试的入口,
并且可以使用本地JSON文件,模拟网络请求
使用说明如下:
http://pan.baidu.com/s/1nts0U9N
代码如下:
#import "BaseViewController.h"@interface TestBackdoorViewController : BaseViewController+ (NSDictionary *)getModelFromJsonNamed:(NSString *)name;@end
//// TestBackdoorViewController.m// HongKongAirlines//// Created by Realank on 15/9/8.// Copyright (c) 2015年 BBDTEK. All rights reserved.////本类用于测试入口界面,防止路经过深,影响开发效率#import "TestBackdoorViewController.h"#import "YRJSONAdapter.h"#import "OrderManagerMobileDetailsWrapperModel.h"#import "RefundNoticeViewController.h"#import "RefundDetailViewController.h"#import "PopUpBigViewForNotice.h"#import "RefundChooseReasonViewController.h"#import "AnnnualTicketUseDetailViewController.h"#import "NewAnnualOrderDetailModel.h"#import "AnnnualUseTicketDetailModel.h"#import "JPQucikRegister.h"#define TEST_ITEM_NUM 10;@interface TestBackdoorViewController ()<UITableViewDataSource,UITableViewDelegate>@property (weak, nonatomic) IBOutlet UITableView *tableView;@end@implementation TestBackdoorViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. self.tableView.delegate = self; self.tableView.dataSource = self; self.title = @"测试界面用入口";}#pragma mark - 用户自定义方法,用于添加测试项//添加测试测试项,请填写如下两个方法//给测试项起名,//确定一个测试测试项的名字,和列表中的位置,然后返回这个名字-(NSString *)nameForTestItems:(NSInteger)index { switch (index) { case 0: return @"打log测试"; case 1: return @"打印json字典测试"; case 2: return @"退票测试入口"; case 3: return @"测试项4"; case 4: return @"测试项5"; //以此类推。。。 } return @"";}//响应测试项点击进入的操作,//创建你的view controller,然后赋值model,推入-(void)chooseTestItems:(NSInteger)index { switch (index) { case 0: NSLog(@"第一条测试"); return; case 1: NSLog(@"获取的json字典:\n%@",[self getModelFromJson]); return; case 2: { NSLog(@"退票测试入口"); NSError *error; OrderManagerMobileDetailsWrapperModel *mobileWrapper = [[OrderManagerMobileDetailsWrapperModel alloc] initWithDictionary:[self getModelFromJson] error:&error]; //退款须知 RefundNoticeViewController *noticeVC = [[RefundNoticeViewController alloc] initWithNibName:nil bundle:nil]; noticeVC.mobileWrapModel = mobileWrapper; //[self.navigationController pushViewController:noticeVC animated:YES]; RefundDetailViewController *refundDetailTVC = [[RefundDetailViewController alloc] initWithNibName:nil bundle:nil]; refundDetailTVC.isNeedDetail = NO; refundDetailTVC.mobileWrapModel = mobileWrapper; // refundDetailTVC.contact = self.contact; [self.navigationController pushViewController:refundDetailTVC animated:YES]; return; } case 3: { JPQucikRegister *jpRegist = [JPQucikRegister alertView]; [jpRegist show]; return; } case 4: { RefundChooseReasonViewController *vc = [[RefundChooseReasonViewController alloc]initWithNibName:@"RefundChooseReasonViewController" bundle:nil]; [self.navigationController pushViewController:vc animated:YES]; } //以此类推。。。 case 5: { NewAnnualOrderDetailModel *orderDetailModel = [[NewAnnualOrderDetailModel alloc] initWithDictionary:[self getModelFromJson] error:nil]; AnnnualUseTicketDetailModel *userDetailModel = [[AnnnualUseTicketDetailModel alloc]initWithDictionary:[TestBackdoorViewController getModelFromJsonNamed:@"secondTestModel"] error:nil]; AnnnualTicketUseDetailViewController *useDetailVC = [[AnnnualTicketUseDetailViewController alloc]initWithNibName:@"AnnnualTicketUseDetailViewController" bundle:nil]; useDetailVC.orderNum = orderDetailModel.order.annualOrderNum; NewAnnualOrderDetailUserInfo *userInfo = orderDetailModel.useInfos[0]; useDetailVC.ticketNo = userInfo.etktNo; useDetailVC.orderDetail = orderDetailModel; useDetailVC.userDetailModel = userDetailModel; [self.navigationController pushViewController:useDetailVC animated:YES]; } } NSLog(@"没有人响应这个测试入口");}#pragma mark - 工具方法,用于辅助实现测试//模拟用户获取的json网络数据,将假想的数据放入testModel.json,即可通过//本函数获得字典数据- (NSDictionary *)getModelFromJson{ NSString *path = [[NSBundle mainBundle] pathForResource:@"testModel" ofType:@"json"]; NSData *jsonData = [[NSData alloc] initWithContentsOfFile:path]; NSDictionary *modelDict = [jsonData objectFromJSONData]; return modelDict;}+ (NSDictionary *)getModelFromJsonNamed:(NSString *)name{ if ([name isEqualToString:@"testModel"]) { NSLog(@"请不要使用testModel文件,这个是给TestBackdoorViewController私有使用的,请自己创建一个json文件"); return nil; } NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"json"]; NSData *jsonData = [[NSData alloc] initWithContentsOfFile:path]; NSDictionary *modelDict = [jsonData objectFromJSONData]; return modelDict;}#pragma mark - 显示测试入口用的方法,不需要修改//下面的内容请不要关心,无需修改- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"testcell"]; NSString *title = [self nameForTestItems:indexPath.row]; if (!title || [title isEqualToString:@""]) { title= [NSString stringWithFormat:@"%ld",(long)indexPath.row]; } cell.textLabel.text = title; cell.textLabel.textColor = [UIColor redColor]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; return cell;}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self chooseTestItems:indexPath.row];}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44.0f;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return TEST_ITEM_NUM;}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1;}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.}*/@end
0 0
- 测试UI的快捷入口
- Cocos快捷入口
- AngularJS快捷入口
- 简单快捷的Amaze UI框架搭建
- 测试SQL连接的快捷方法
- MSSQL数据库测试连接的快捷方法
- [深入JUnit] 测试运行的入口
- APP的UI测试
- 更新UI的测试
- APP的UI测试
- Unity UGUI——UI控件的鼠标快捷操作
- 文件夹添加右键DOS快捷入口
- 文件夹添加右键DOS快捷入口
- 软件测试工作需掌握的Linux的快捷…
- 最快捷测试Ext对象属性的方法
- 失控的UI自动化测试
- Sencha应用程序的UI测试
- App-UI测试的主要内容
- IDEA Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executin
- Android代码优化小技巧总结
- HTML5试题
- 对多线程通信的优化
- 选择控件 UISegmentedController
- 测试UI的快捷入口
- Minimum Window Substring 最小窗口覆盖所有字串
- IOS 项目的框架搭建
- cpuacct (CPU Accounting Controller)
- CSS的半透明处理
- 转 -- mariadb galera集群配置
- Android string %1$s %1$d
- 从无到有(统计、请求、MVC、模块化)H5开发须知--一个完整的实例
- eclipse debug技巧