summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2021-10-21 09:11:02 -0400
committerJoel Fischer <joeljfischer@gmail.com>2021-10-21 09:11:02 -0400
commit731ad74437e7ef62347cd21b8ef82b099c2877c4 (patch)
treeaf6f753813f2024706ecdbc3e164cef1be427ad2
parent3da39d926149242828fd641e2615302356e04d78 (diff)
downloadsdl_ios-731ad74437e7ef62347cd21b8ef82b099c2877c4.tar.gz
Fix submenu layout is not copied on menu cellsbugfix/issue-2048-copying-menu-cell-no-submenu-layout
-rw-r--r--SmartDeviceLink/public/SDLMenuCell.m1
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m32
2 files changed, 23 insertions, 10 deletions
diff --git a/SmartDeviceLink/public/SDLMenuCell.m b/SmartDeviceLink/public/SDLMenuCell.m
index 4f780a579..845d10f04 100644
--- a/SmartDeviceLink/public/SDLMenuCell.m
+++ b/SmartDeviceLink/public/SDLMenuCell.m
@@ -134,6 +134,7 @@ NS_ASSUME_NONNULL_BEGIN
if (_subCells.count > 0) {
newCell.subCells = [[NSArray alloc] initWithArray:_subCells copyItems:YES];
+ newCell->_submenuLayout = _submenuLayout;
}
return newCell;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m
index 4958e7674..02bb07a1c 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m
@@ -15,6 +15,8 @@ describe(@"a menu cell", ^{
__block NSString *someTertiaryTitle = nil;
__block SDLArtwork *someArtwork = nil;
__block SDLArtwork *someSecondaryArtwork = nil;
+ __block NSArray<NSString *> *someVoiceCommands = nil;
+ __block NSArray<SDLMenuCell *> *someSubcells = nil;
beforeEach(^{
someTitle = @"Some Title";
@@ -22,19 +24,11 @@ describe(@"a menu cell", ^{
someTertiaryTitle = @"Some Title 3";
someArtwork = [[SDLArtwork alloc] initWithData:[[NSData alloc] initWithBase64EncodedString:@"data" options:kNilOptions] name:@"Some artwork" fileExtension:@"png" persistent:NO];
someSecondaryArtwork = [[SDLArtwork alloc] initWithData:[[NSData alloc] initWithBase64EncodedString:@"data" options:kNilOptions] name:@"Some artwork 2" fileExtension:@"png" persistent:NO];
+ someVoiceCommands = @[@"some command"];
+ someSubcells = @[[[SDLMenuCell alloc] initWithTitle:@"Test Subcell" secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) {}], [[SDLMenuCell alloc] initWithTitle:@"Test Subcell2" secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) {}]];
});
describe(@"initializing", ^{
- __block NSArray<NSString *> *someVoiceCommands = nil;
- __block NSArray<SDLMenuCell *> *someSubcells = nil;
-
- beforeEach(^{
- someVoiceCommands = @[@"some command"];
-
- SDLMenuCell *subcell = [[SDLMenuCell alloc] initWithTitle:@"Hello" secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) {}];
- someSubcells = @[subcell];
- });
-
it(@"should set initWithTitle:icon:submenuLayout:subCells: propertly", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@@ -135,6 +129,24 @@ describe(@"a menu cell", ^{
expect([testCell isEqual:testCell2]).to(beFalse());
});
});
+
+ describe(@"copying a cell", ^{
+ context(@"a submenu cell", ^{
+ it(@"should copy correctly", ^{
+ testCell = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:someArtwork secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:someSubcells];
+ testCell2 = [testCell copy];
+
+ expect(testCell2).to(equal(testCell));
+ });
+ });
+
+ context(@"a normal cell", ^{
+ testCell = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:someArtwork secondaryArtwork:someSecondaryArtwork voiceCommands:someVoiceCommands handler:^(SDLTriggerSource _Nonnull triggerSource) {}];
+ testCell2 = [testCell copy];
+
+ expect(testCell2).to(equal(testCell));
+ });
+ });
});
QuickSpecEnd