flutter_logan_exampleTests.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // flutter_logan_exampleTests.m
  3. // flutter_logan_exampleTests
  4. //
  5. // Created by M小军 on 2019/12/20.
  6. // Copyright © 2019 The Chromium Authors. All rights reserved.
  7. //
  8. #import <XCTest/XCTest.h>
  9. #import <Kiwi/Kiwi.h>
  10. #import "FlutterLoganPlugin.h"
  11. #import <Flutter/Flutter.h>
  12. SPEC_BEGIN(FlutterLogan)
  13. describe(@"Flutter Logan test", ^{
  14. context(@"func test", ^{
  15. FlutterLoganPlugin *plugin = [FlutterLoganPlugin new];
  16. it(@"init", ^{
  17. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  18. __block NSNumber *callBack = nil;
  19. FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"init" arguments:@{
  20. @"aesKey": @"0123456789012345",
  21. @"aesIv": @"0123456789012345",
  22. @"MaxFileLen": @(1024*1024*10)}];
  23. [plugin handleMethodCall:call result:^(id _Nullable result) {
  24. callBack = result;
  25. dispatch_semaphore_signal(semaphore);
  26. }];
  27. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  28. [[callBack shouldNot] beNil];
  29. });
  30. it(@"log", ^{
  31. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  32. __block NSNumber *callBack = nil;
  33. FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"log" arguments:@{
  34. @"type": @10,
  35. @"log": @"this is a test log"}];
  36. [plugin handleMethodCall:call result:^(id _Nullable result) {
  37. callBack = result;
  38. dispatch_semaphore_signal(semaphore);
  39. }];
  40. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  41. [[callBack should] beNil];
  42. });
  43. it(@"flush", ^{
  44. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  45. __block NSNumber *callBack = nil;
  46. FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"flush" arguments:@{}];
  47. [plugin handleMethodCall:call result:^(id _Nullable result) {
  48. callBack = result;
  49. dispatch_semaphore_signal(semaphore);
  50. }];
  51. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  52. [[callBack should] beNil];
  53. });
  54. it(@"getUploadPath", ^{
  55. __block NSNumber *callBack = nil;
  56. FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"getUploadPath" arguments:@{@"date" : @"2019-12-23"}];
  57. [plugin handleMethodCall:call result:^(id _Nullable result) {
  58. callBack = result;
  59. }];
  60. [[callBack shouldNotEventuallyBeforeTimingOutAfter(3)] beNil];
  61. });
  62. it(@"upload", ^{
  63. __block NSNumber *callBack = nil;
  64. FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"upload" arguments:@{
  65. @"date" : @"2019-12-23",
  66. @"url" : @"test/url",
  67. @"appId" : @"FlutterTestAppId",
  68. @"unionId" : @"FlutterTestAppId",
  69. @"deviceId" : @"FlutterTestAppId"
  70. }];
  71. [plugin handleMethodCall:call result:^(id _Nullable result) {
  72. callBack = result;
  73. NSLog(@"%@ ******** ",result);
  74. }];
  75. [[callBack shouldNotEventuallyBeforeTimingOutAfter(3)] beNil];
  76. });
  77. it(@"cleanLogs", ^{
  78. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  79. __block NSNumber *callBack = nil;
  80. FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"cleanAllLogs" arguments:@{}];
  81. [plugin handleMethodCall:call result:^(id _Nullable result) {
  82. callBack = result;
  83. dispatch_semaphore_signal(semaphore);
  84. }];
  85. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  86. [[callBack should] beNil];
  87. });
  88. });
  89. });
  90. SPEC_END