Skip to content

Commit

Permalink
fix: sdk测量协议3.0再次修整,去除不必要的注释以及修改命名规则,去掉部分无法使用的测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
CaicaiNo committed Aug 26, 2020
1 parent c7be8eb commit 2420589
Show file tree
Hide file tree
Showing 66 changed files with 975 additions and 3,483 deletions.
239 changes: 117 additions & 122 deletions Example/Example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions Example/Example/AppDelegate.m
Expand Up @@ -31,17 +31,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.configuation = [[GrowingConfiguration alloc] initWithProjectId:kGrowingProjectId launchOptions:launchOptions];
[self.configuation setLogEnabled:YES];
self.configuation.samplingRate = 1.0;
// self.configuation.urlScheme = @"hello_url_scheme";
self.configuation.cellularDataLimit = 1;
// self.configuation.dataUploadEnabled = NO;
// self.configuation.dataTrackEnabled = NO;
self.configuation.impressionScale = 1.0;

// 自定义相关host设置
// [configuration setDataTrackHost:@"http://k8s-mobile-www.growingio.com"];
// [configuration setWebSocketHost:@"ws://k8s-mobile-gta.growingio.com"];
// [configuration setAdvertisementHost:@"http://k8s-mobile-www.growingio.com"];

[Growing startWithConfiguration:self.configuation];

NSString *trackSdkVersion = [Growing getVersion];
Expand Down
61 changes: 29 additions & 32 deletions Example/Example/UICategoryTests/GIOCollectionViewController.m
Expand Up @@ -7,20 +7,23 @@
//

#import "GIOCollectionViewController.h"

#import "GIOCollectionViewCell.h"

@interface GIOCollectionViewController () <UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@interface GIOCollectionViewController () <UICollectionViewDelegate,
UICollectionViewDataSource,
UICollectionViewDelegateFlowLayout>

@property (nonatomic, strong) UICollectionView *mainCollectionView;
@property (nonatomic, strong) NSArray <NSString *> *imagesArray;
@property (nonatomic, strong) NSArray<NSString *> *imagesArray;

@end

@implementation GIOCollectionViewController

- (void)viewDidLoad {
[super viewDidLoad];

[self.view addSubview:self.mainCollectionView];
}

Expand All @@ -31,20 +34,20 @@ - (void)didReceiveMemoryWarning {

#pragma mark UICollectionViewDelegate, UICollectionViewDataSource

//一共有几组
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 3 ;
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 3;
}

//每组几个cell
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.imagesArray.count ;
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.imagesArray.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
GIOCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GIOCollectionViewCell" forIndexPath:indexPath];
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
GIOCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GIOCollectionViewCell"
forIndexPath:indexPath];

NSString *title = [NSString stringWithFormat:(@"%ld张图片"),(long)indexPath.row+1];
NSString *title = [NSString stringWithFormat:(@"%ld张图片"), (long)indexPath.row + 1];
[cell configWithTitle:title andIamgeName:self.imagesArray[indexPath.row]];
return cell;
}
Expand All @@ -57,46 +60,40 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa

- (UICollectionView *)mainCollectionView {
if (!_mainCollectionView) {

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
//设置collectionView滚动方向
//[layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
//设置headerView的尺寸大小
layout.headerReferenceSize = CGSizeMake(self.view.frame.size.width, 10);
//该方法也可以设置itemSize
layout.itemSize =CGSizeMake(110, 150);
layout.itemSize = CGSizeMake(110, 150);

_mainCollectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
_mainCollectionView.backgroundColor = [UIColor clearColor];

[_mainCollectionView registerNib:[UINib nibWithNibName:@"GIOCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"GIOCollectionViewCell"];


[_mainCollectionView registerNib:[UINib nibWithNibName:@"GIOCollectionViewCell" bundle:nil]
forCellWithReuseIdentifier:@"GIOCollectionViewCell"];

//注册headerView 此处的ReuseIdentifier 必须和 cellForItemAtIndexPath 方法中 一致 均为reusableView
[_mainCollectionView registerClass:[UICollectionReusableView class]
forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"reusableView"];
//4.设置代理
_mainCollectionView.accessibilityIdentifier=@"GIOCollectionView";

// 4.设置代理
_mainCollectionView.accessibilityIdentifier = @"GIOCollectionView";
_mainCollectionView.delegate = self;
_mainCollectionView.dataSource = self;
}

return _mainCollectionView;
}

- (NSArray<NSString *> *)imagesArray {
if (!_imagesArray) {
_imagesArray = @[@"cycle_01.jpg",
@"cycle_02.jpg",
@"cycle_03.jpg",
@"cycle_04.jpg",
@"cycle_03.jpg",
@"cycle_04.jpg",
@"cycle_05.jpg",
@"cycle_06.jpg",
@"cycle_07.jpg",
@"cycle_08.jpg"];
_imagesArray = @[
@"cycle_01.jpg", @"cycle_02.jpg", @"cycle_03.jpg", @"cycle_04.jpg", @"cycle_03.jpg", @"cycle_04.jpg",
@"cycle_05.jpg", @"cycle_06.jpg", @"cycle_07.jpg", @"cycle_08.jpg"
];
}
return _imagesArray;
}
Expand Down
55 changes: 12 additions & 43 deletions Example/Example/UICategoryTests/GIOLabelAttributeViewController.m
Expand Up @@ -8,12 +8,10 @@

#import "GIOLabelAttributeViewController.h"
//#import "GrowingAutoTracker.h"
#import <GrowingAutoTracker.h>

#import <CoreLocation/CoreLocation.h>
#import <GrowingAutoTracker.h>


@interface GIOLabelAttributeViewController ()
@interface GIOLabelAttributeViewController ()
@end

@implementation GIOLabelAttributeViewController
Expand All @@ -32,55 +30,29 @@ - (void)didReceiveMemoryWarning {

//设置alpha的值为0.005
- (IBAction)setAlphaSmall:(id)sender {
self.CheckAlpLabel.alpha=0.005;
self.CheckAlpLabel.alpha = 0.005;
NSLog(@"设置alpha的值为0.005");
}
//设置alpha的值为1
- (IBAction)setAlphLarge:(id)sender {
self.CheckAlpLabel.alpha=1;
self.CheckAlpLabel.alpha = 1;
NSLog(@"设置alpha的值为1");
}
//隐藏label
- (IBAction)hiddenLabel:(id)sender {
self.CheckHiddenLabel.hidden=TRUE;
self.CheckHiddenLabel.hidden = TRUE;
NSLog(@"隐藏Label标签!");
}
- (IBAction)showLabel:(id)sender {
self.CheckHiddenLabel.hidden=false;
self.CheckHiddenLabel.hidden = false;
NSLog(@"显示Label标签!");
}
//弹出浮层测试
- (IBAction)showAlertTest:(id)sender {
//alert第一种形式
// NSString *title = NSLocalizedString(@"A Short Title Is Best", nil);
// NSString *message = NSLocalizedString(@"A message should be a short, complete sentence.", nil);
// NSString *cancelButtonTitle = NSLocalizedString(@"Cancel", nil);
// NSString *otherButtonTitleOne = NSLocalizedString(@"Choice One", nil);
// NSString *otherButtonTitleTwo = NSLocalizedString(@"Choice Two", nil);
//
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitleOne, otherButtonTitleTwo, nil];
// alert.window.windowLevel = 200;
// [alert show];

//alert第二种形式
// UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Alert Test" message:@"Test Alert buttton action!" preferredStyle:UIAlertControllerStyleAlert];
// UIAlertAction *yesAction=[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
// NSLog(@"Click OK Button of Alert!");
// }];
//
// UIAlertAction *noAction=[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
// NSLog(@"Click Cancel Button of Alert!");
// }];
// [alert addAction:yesAction];
// [alert addAction:noAction];
// [self presentViewController:alert animated:true completion:nil];

[self showalert];

}

-(void)showalert
{
- (void)showalert {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView"
message:@"弹出式对话框相关测试!"
delegate:self
Expand All @@ -90,21 +62,18 @@ -(void)showalert
[alert show];
}


//设置GIO不采集数据
- (IBAction)growingNotTrack:(id)sender {
NSLog(@"GrowingIO 不采集点击事件!");
}

//监听点击事件 代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
{
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[self showalert];
}
NSString *btnTitle = [alertView buttonTitleAtIndex:buttonIndex];
NSLog(@"弹出框,单击了按钮:%@",btnTitle);
}
NSString *btnTitle = [alertView buttonTitleAtIndex:buttonIndex];
NSLog(@"弹出框,单击了按钮:%@", btnTitle);
}

@end
Expand Up @@ -14,7 +14,6 @@ @interface GIOBaseViewController ()

@implementation GIOBaseViewController


- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
Expand All @@ -24,14 +23,4 @@ - (void)viewDidLoad {
// Do any additional setup after loading the view.
}

/*
#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
Expand Up @@ -7,6 +7,7 @@
//

#import "GIOChildsAddViewController.h"

#import "GIOBaseViewController.h"
@interface GIOChildsAddViewController ()

Expand All @@ -17,34 +18,22 @@ @implementation GIOChildsAddViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.

CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat height = [UIScreen mainScreen].bounds.size.height;
GIOBaseViewController *A = [[GIOBaseViewController alloc] init];
A.view.frame = CGRectMake(0, 0, width, height - 200);
A.view.backgroundColor = [UIColor greenColor];

GIOBaseViewController *B = [[GIOBaseViewController alloc] init];
B.view.frame = CGRectMake(0, height - 200, width,200);
B.view.frame = CGRectMake(0, height - 200, width, 200);
B.view.backgroundColor = [UIColor redColor];

[self addChildViewController:A];
[self addChildViewController:B];

[self.view addSubview:A.view];
[self.view addSubview:B.view];
}



/*
#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
Expand Up @@ -19,14 +19,4 @@ - (void)viewDidLoad {
// Do any additional setup after loading the view.
}

/*
#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
27 changes: 1 addition & 26 deletions Example/ExampleTests/GrowingIO_ExampleTests.m
Expand Up @@ -28,42 +28,17 @@ - (void)afterEach {
}

- (void)setUp {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
self.continueAfterFailure = NO;

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}

- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.

}

- (void)testExample {
// UI tests must launch the application that they test.
XCUIApplication *app = [[XCUIApplication alloc] init];
[app launch];

// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

//- (void)testExample {
// //构造VIEW_CHANGE事件
// [[viewTester usingLabel:@"UserName"] enterText:@"GrowingIOUser\n"];
// [[viewTester usingLabel:@"PassWord"] waitToBecomeFirstResponder];
// [[viewTester usingLabel:@"PassWord"] waitForView];
// [[viewTester usingLabel:@"PassWord"] enterText:@"GrowingIO" expectedResult:@"GrowingIO"];
//
// //MockEventQueue 缓存事件并提供了几个高效的接口
// NSUInteger chngEventCount = [[MockEventQueue eventsFor:@"VIEW_CHANGE"] count];
//
// NSUInteger acvEventCount = [[MockEventQueue eventsFor:@"app_activate"] count];
//
// //使用XCTAssert断言,该部分可参考apple 文档
// XCTAssertEqual(chngEventCount, 1);
// XCTAssertEqual(acvEventCount, 1);
//}

@end

0 comments on commit 2420589

Please sign in to comment.