Skip to content

Commit

Permalink
Merge pull request #2053 from smartdevicelink/bugfix/issue-2048-copyi…
Browse files Browse the repository at this point in the history
…ng-menu-cell-no-submenu-layout

Fix submenu layout is not copied on menu cells
  • Loading branch information
joeljfischer authored Oct 21, 2021
2 parents 99f0622 + 731ad74 commit 53e43be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions SmartDeviceLink/public/SDLMenuCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ - (id)copyWithZone:(nullable NSZone *)zone {

if (_subCells.count > 0) {
newCell.subCells = [[NSArray alloc] initWithArray:_subCells copyItems:YES];
newCell->_submenuLayout = _submenuLayout;
}

return newCell;
Expand Down
32 changes: 22 additions & 10 deletions SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,20 @@
__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";
someSecondaryTitle = @"Some Title 2";
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"
Expand Down Expand Up @@ -135,6 +129,24 @@
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

0 comments on commit 53e43be

Please sign in to comment.