summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-07-29 14:28:11 -0400
committerGitHub <noreply@github.com>2020-07-29 14:28:11 -0400
commit3f354ae3a745426f3f9ea79f54239d5e33702ca1 (patch)
tree8810378de346f12ffd14de909f00f74a0929f740
parent00adbe2c16d23abeadbe838c9b73115e29e7f6b6 (diff)
parent1386339ee0082a36becd33d234f1f5974712274e (diff)
downloadsdl_ios-3f354ae3a745426f3f9ea79f54239d5e33702ca1.tar.gz
Merge pull request #1715 from LuxoftSDL/bugfix/issue_0200_removing-url-parameter-max-length
[SDL 0200] - Removing url parameter max length
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m68
1 files changed, 59 insertions, 9 deletions
diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m
index 63b2bbd58..a4a21e7c4 100644
--- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m
@@ -2,18 +2,17 @@
// SDLOnSystemRequestSpec.m
// SmartDeviceLink
-
#import <Foundation/Foundation.h>
-
-#import <Quick/Quick.h>
#import <Nimble/Nimble.h>
+#import <Quick/Quick.h>
#import "SDLFileType.h"
-#import "SDLRPCParameterNames.h"
-#import "SDLRPCFunctionNames.h"
#import "SDLOnSystemRequest.h"
+#import "SDLRPCFunctionNames.h"
+#import "SDLRPCParameterNames.h"
#import "SDLRequestType.h"
+static NSString *const SDLTestURL = @"https://www.smartdevicelink.com";
QuickSpecBegin(SDLOnSystemRequestSpec)
@@ -23,7 +22,7 @@ describe(@"Getter/Setter Tests", ^ {
testNotification.requestType = SDLRequestTypeFileResume;
testNotification.requestSubType = @"subtype";
- testNotification.url = @"www.google.com";
+ testNotification.url = SDLTestURL;
testNotification.timeout = @52345;
testNotification.fileType = SDLFileTypePNG;
testNotification.offset = @2532678684;
@@ -31,7 +30,7 @@ describe(@"Getter/Setter Tests", ^ {
expect(testNotification.requestType).to(equal(SDLRequestTypeFileResume));
expect(testNotification.requestSubType).to(equal(@"subtype"));
- expect(testNotification.url).to(equal(@"www.google.com"));
+ expect(testNotification.url).to(equal(SDLTestURL));
expect(testNotification.timeout).to(equal(@52345));
expect(testNotification.fileType).to(equal(SDLFileTypePNG));
expect(testNotification.offset).to(equal(@2532678684));
@@ -43,7 +42,7 @@ describe(@"Getter/Setter Tests", ^ {
@{SDLRPCParameterNameParameters:
@{SDLRPCParameterNameRequestType:SDLRequestTypeFileResume,
SDLRPCParameterNameRequestSubType: @"subtype",
- SDLRPCParameterNameURL:@"www.google.com",
+ SDLRPCParameterNameURL:SDLTestURL,
SDLRPCParameterNameTimeout:@52345,
SDLRPCParameterNameFileType:SDLFileTypePNG,
SDLRPCParameterNameOffset:@2532678684,
@@ -56,7 +55,7 @@ describe(@"Getter/Setter Tests", ^ {
expect(testNotification.requestType).to(equal(SDLRequestTypeFileResume));
expect(testNotification.requestSubType).to(equal(@"subtype"));
- expect(testNotification.url).to(equal([@"www.google.com" mutableCopy]));
+ expect(testNotification.url).to(equal(SDLTestURL));
expect(testNotification.timeout).to(equal(@52345));
expect(testNotification.fileType).to(equal(SDLFileTypePNG));
expect(testNotification.offset).to(equal(@2532678684));
@@ -74,6 +73,57 @@ describe(@"Getter/Setter Tests", ^ {
expect(testNotification.offset).to(beNil());
expect(testNotification.length).to(beNil());
});
+
+ it(@"Should set and get url correctly (zero length url)", ^{
+ SDLOnSystemRequest *testRequest = [[SDLOnSystemRequest alloc] init];
+ NSString *testURL = @"";
+ testRequest.url = testURL;
+ expect(testRequest.url).to(equal(testURL));
+
+ NSURL *nsurl = [NSURL URLWithString:testURL];
+ expect(nsurl).notTo(beNil());
+ expect(nsurl.absoluteString).to(equal(testURL));
+ });
+
+ it(@"Should set and get url correctly (1000 sym long url)", ^{
+ const int size = 1000;
+ SDLOnSystemRequest* testRequest = [[SDLOnSystemRequest alloc] init];
+ NSMutableString *testURL = [NSMutableString stringWithCapacity:1024];
+ [testURL setString:SDLTestURL];
+ while(size > testURL.length) {
+ [testURL appendString:@"/testcomponent"];
+ }
+ if (size < testURL.length) {
+ const NSRange range = NSMakeRange(size, testURL.length - size);
+ [testURL deleteCharactersInRange:range];
+ }
+ testRequest.url = testURL;
+ expect(testRequest.url).to(equal(testURL));
+
+ NSURL *nsurl = [NSURL URLWithString:testURL];
+ expect(nsurl).notTo(beNil());
+ expect(nsurl.absoluteString).to(equal(testURL));
+ });
+
+ it(@"Should set and get url correctly (extra long url)", ^{
+ const int size = 1024 * 1024;
+ SDLOnSystemRequest *testRequest = [[SDLOnSystemRequest alloc] init];
+ NSMutableString *testURL = [NSMutableString stringWithCapacity:size + 20];
+ [testURL setString:SDLTestURL];
+ while(size > testURL.length) {
+ [testURL appendString:@"/testcomponent"];
+ }
+ if (size < testURL.length) {
+ const NSRange range = NSMakeRange(size, testURL.length - size);
+ [testURL deleteCharactersInRange:range];
+ }
+ testRequest.url = testURL;
+ expect(testRequest.url).to(equal(testURL));
+
+ NSURL *nsurl = [NSURL URLWithString:testURL];
+ expect(nsurl).notTo(beNil());
+ expect(nsurl.absoluteString).to(equal(testURL));
+ });
});
QuickSpecEnd