def test_layer_record_channel_sizes():
    layer_record = LayerRecord(
        left=0,
        top=0,
        right=100,
        bottom=120,
        channel_info=[
            ChannelInfo(id=ChannelID.CHANNEL_0),
            ChannelInfo(id=ChannelID.USER_LAYER_MASK),
            ChannelInfo(id=ChannelID.REAL_USER_LAYER_MASK),
        ],
        mask_data=MaskData(
            left=20,
            top=20,
            right=80,
            bottom=90,
            real_left=10,
            real_top=10,
            real_right=90,
            real_bottom=100,
        ))
    channel_sizes = layer_record.channel_sizes
    assert len(channel_sizes) == 3
    assert channel_sizes[0] == (100, 120)
    assert channel_sizes[1] == (60, 70)
    assert channel_sizes[2] == (80, 90)
def test_mask_data_failure(args):
    check_write_read(MaskData(**args))
    exit(1)

if not content_layer.has_mask():
    # create artifical mask from rectangular area of content layer
    left, top, right, bottom = content_layer.bbox
    width, height = content_layer.width, content_layer.height
    depth, version = psd.depth, psd.version
    # artificial channeldata, channelinfo, maskdata mimicking ones from iPhone11
    data = b'\xff' * (width * height)
    channel_data = ChannelData(compression=Compression.RLE)
    channel_data.set_data(data, width, height, depth, version)
    channel_info = ChannelInfo(id=ChannelID.USER_LAYER_MASK, length=channel_data._length)
    mask_data = MaskData(
        top=top,
        left=left,
        bottom=bottom,
        right=right,
        background_color=0
    )
else:
    # find mask channel info/data
    channel_index, channel_info = next((
        (i, info) 
        for i, info in enumerate(content_layer._record.channel_info)
        if info.id == ChannelID.USER_LAYER_MASK
    ))
    channel_data = content_layer._channels[channel_index]
    mask_data = content_layer._record.mask_data
    # remove mask from content layer
    del content_layer._record.channel_info[channel_index]
    del content_layer._channels[channel_index]