sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "TRGB.H" sl@0: sl@0: sl@0: CTRgb::CTRgb(CTestStep* aStep): sl@0: CTGraphicsBase(aStep) sl@0: { sl@0: INFO_PRINTF1(_L("Testing TRgb colour functions")); sl@0: } sl@0: sl@0: void CTRgb::RunTestCaseL(TInt aCurTestCase) sl@0: { sl@0: ((CTRgbStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(aCurTestCase) sl@0: { sl@0: case 1: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0001 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0001")); sl@0: TestGray2(); sl@0: break; sl@0: case 2: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0002 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0002")); sl@0: TestGray4(); sl@0: break; sl@0: case 3: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0003 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0003")); sl@0: TestGray16(); sl@0: break; sl@0: case 4: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0004 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0004")); sl@0: TestGray256(); sl@0: break; sl@0: case 5: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0005 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0005")); sl@0: TestColor16(); sl@0: break; sl@0: case 6: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0006 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0006")); sl@0: TestColor256(); sl@0: break; sl@0: case 7: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0007 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0007")); sl@0: TestColor4K(); sl@0: break; sl@0: case 8: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0008 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0008")); sl@0: TestColor64K(); sl@0: break; sl@0: case 9: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0009 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0009")); sl@0: TestColor16M(); sl@0: break; sl@0: case 10: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0010 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0010")); sl@0: TestColor16MU(); sl@0: break; sl@0: case 11: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0011 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0011")); sl@0: TestColor16MA(); sl@0: break; sl@0: case 12: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0012 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0012")); sl@0: TestColor256Util(); sl@0: break; sl@0: case 13: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-GDI-RGB-0013 sl@0: */ sl@0: ((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0013")); sl@0: TestColor16MAP(); sl@0: break; sl@0: case 14: sl@0: ((CTRgbStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTRgbStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTRgbStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: /** sl@0: Test Gray2 colour set sl@0: sl@0: Cycle through each Gray2 colour & compare the grayscale value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Gray2 TRgb value with a subset of the Gray256 colour-set. sl@0: sl@0: Expect the conversion from index value to grayscale colour value & back again produces identical value. sl@0: Expect the Gray2 rgb colour set forms a subset of the Gray256 colour rgb set sl@0: */ sl@0: void CTRgb::TestGray2() sl@0: { sl@0: INFO_PRINTF1(_L("Gray2")); sl@0: sl@0: for (TInt index = 0; index < 2; index++) sl@0: { sl@0: TRgb color = TRgb::Gray2(index); sl@0: TEST(color.Gray2() == index); sl@0: } sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TEST(color.Gray2() == color.Gray256() / 128); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Cycle through each Gray4 colour & compare the grayscale value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Gray4 TRgb colour value with a subset of the Gray256 colour-set. sl@0: sl@0: Expect conversion from index value to grayscale colour value & back again produces identical value. sl@0: Expect the Gray4 rgb colour set forms a subset of the Gray256 colour rgb set sl@0: */ sl@0: void CTRgb::TestGray4() sl@0: { sl@0: INFO_PRINTF1(_L("Gray4")); sl@0: sl@0: for (TInt index = 0; index < 4; index++) sl@0: { sl@0: TRgb color = TRgb::Gray4(index); sl@0: TEST(color.Gray4() == index); sl@0: } sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TEST(color.Gray4() == color.Gray256() / 64); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Cycle through each Gray16 colour & compare the grayscale value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Gray16 TRgb value with a subset of the Gray256 colour-set. sl@0: sl@0: Expect the conversion from index value to grayscale colour value & back again produces identical value. sl@0: Expect the Gray16 rgb colour set forms a subset of the Gray256 colour rgb set sl@0: */ sl@0: void CTRgb::TestGray16() sl@0: { sl@0: INFO_PRINTF1(_L("Gray16")); sl@0: sl@0: for (TInt index = 0; index < 16; index++) sl@0: { sl@0: TRgb color = TRgb::Gray16(index); sl@0: TEST(color.Gray16() == index); sl@0: } sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TEST(color.Gray16() == color.Gray256() / 16); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Cycle through each Gray256 colour & compare the grayscale value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Gray256 TRgb colour value with the value produced by generic algorithm sl@0: sl@0: Expect the conversion from index value to grayscale colour value & back again produces identical value. sl@0: Confirm the algorithm used to produce Gray256 colour set sl@0: */ sl@0: void CTRgb::TestGray256() sl@0: { sl@0: INFO_PRINTF1(_L("Gray256")); sl@0: sl@0: for (TInt index = 0; index < 256; index++) sl@0: { sl@0: TRgb color = TRgb::Gray256(index); sl@0: TEST(color.Gray256() == index); sl@0: } sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TInt algGray256 = (((value & 0xff) * 2) + (((value >> 8) & 0xff) * 5) + ((value >> 16) & 0xff)) / 8; sl@0: TEST(color.Gray256() == algGray256); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 16 Colour colour set sl@0: sl@0: Cycle through each Color16 colour & test the value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Compare the rgb value for each Color16 colour matches that returned by the DynamicPalette colour palette sl@0: sl@0: Expect the RGB colour value returned matches the 16colour palette sl@0: */ sl@0: void CTRgb::TestColor16() sl@0: { sl@0: INFO_PRINTF1(_L("Color16")); sl@0: sl@0: for (TInt index = 0; index < 16; index++) sl@0: { sl@0: TRgb color = TRgb::Color16(index); sl@0: TEST(color.Color16() == index); sl@0: TEST(TRgb::Color16(index) == TRgb(DynamicPalette::Color16array()[index])); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 256 colour set sl@0: sl@0: Cycle through each Color256 colour & test the value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Compare the rgb value for each Color256 colour against the rgb value returned by the DynamicPalette colour palette sl@0: Cycle through each Color256 colour & confirm it matches the Netscape Colour Cube sl@0: sl@0: Expect the RGB colour returned matches the 256 colour palette sl@0: */ sl@0: void CTRgb::TestColor256() sl@0: { sl@0: INFO_PRINTF1(_L("Color256")); sl@0: sl@0: const TInt mainValues[6] = {0x00, 0x33, 0x66, 0x99, 0xcc, 0xff }; sl@0: const TInt lowerValues[5] = {0x11, 0x22, 0x44, 0x55, 0x77 }; sl@0: const TInt upperValues[5] = {0x88, 0xaa, 0xbb, 0xdd, 0xee }; sl@0: sl@0: TInt index; sl@0: for (index = 0; index < 256; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Color256() == index); sl@0: TEST(TRgb::Color256(index) == TRgb(DynamicPalette::DefaultColor256Util()->iColorTable[index])); sl@0: } sl@0: sl@0: for (index = 0; index < 108; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == mainValues[index % 6]); sl@0: TEST(color.Green() == mainValues[(index / 6) % 6]); sl@0: TEST(color.Blue() == mainValues[(index / 36) % 6]); sl@0: } sl@0: for (; index < 113; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == color.Green()); sl@0: TEST(color.Green() == color.Blue()); sl@0: TEST(color.Blue() == lowerValues[index - 108]); sl@0: } sl@0: for (; index < 118; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == lowerValues[index - 113]); sl@0: TEST(color.Green() == 0); sl@0: TEST(color.Blue() == 0); sl@0: } sl@0: for (; index < 123; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == 0); sl@0: TEST(color.Green() == lowerValues[index - 118]); sl@0: TEST(color.Blue() == 0); sl@0: } sl@0: for (; index < 128; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == 0); sl@0: TEST(color.Green() == 0); sl@0: TEST(color.Blue() == lowerValues[index - 123]); sl@0: } sl@0: for (; index < 133; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == 0); sl@0: TEST(color.Green() == 0); sl@0: TEST(color.Blue() == upperValues[index - 128]); sl@0: } sl@0: for (; index < 138; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == 0); sl@0: TEST(color.Green() == upperValues[index - 133]); sl@0: TEST(color.Blue() == 0); sl@0: } sl@0: for (; index < 143; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == upperValues[index - 138]); sl@0: TEST(color.Green() == 0); sl@0: TEST(color.Blue() == 0); sl@0: } sl@0: for (; index < 148; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == color.Green()); sl@0: TEST(color.Green() == color.Blue()); sl@0: TEST(color.Blue() == upperValues[index - 143]); sl@0: } sl@0: for (; index < 256; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(color.Red() == mainValues[(index - 40) % 6]); sl@0: TEST(color.Green() == mainValues[((index - 40) / 6) % 6]); sl@0: TEST(color.Blue() == mainValues[((index - 40) / 36) % 6]); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 4096 colour set sl@0: sl@0: Cycle through each Color4K colour & compare the colorscale value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Color4K TRgb value against that produced by the algorithm sl@0: sl@0: Confirm the conversion from index value to 4096 colour value & back again produces identical value. sl@0: Confirm the algorithm used to produce 4096 colour set sl@0: */ sl@0: void CTRgb::TestColor4K() sl@0: { sl@0: INFO_PRINTF1(_L("Color4K")); sl@0: sl@0: for (TInt index = 0; index < 4096; index++) sl@0: { sl@0: TRgb color = TRgb::Color4K(index); sl@0: TEST(color.Color4K() == index); sl@0: } sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TInt color4K = ((value & 0xf00000) >> 20) | ((value & 0x00f000) >> 8) | ((value & 0x0000f0) << 4); sl@0: TEST(color.Color4K() == color4K); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 64K colour set sl@0: sl@0: Cycle through each Color64K colour & compare the TRgb value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Color64K TRgb value against that produced by the algorithm sl@0: sl@0: Confirm the conversion from index value to 64K colour value & back again produces identical value. sl@0: Confirm the algorithm used to produce 64K colour set sl@0: */ sl@0: void CTRgb::TestColor64K() sl@0: { sl@0: INFO_PRINTF1(_L("Color64K")); sl@0: sl@0: for (TInt index = 0; index < 65536; index++) sl@0: { sl@0: TRgb color = TRgb::Color64K(index); sl@0: TEST(color.Color64K() == index); sl@0: } sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TInt color64K = ((value & 0xf8) << 8) + ((value & 0xfc00) >> 5) + ((value & 0xf80000) >> 19); sl@0: TEST(color.Color64K() == color64K); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 16M colour set sl@0: sl@0: Cycle through each Color16M colour & compare the TRgb value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Color16M TRgb value against that produced by the algorithm sl@0: sl@0: Confirm the conversion from index value to 16M colour value & back again produces identical value. sl@0: Confirm the algorithm used to produce 16M colour set sl@0: */ sl@0: void CTRgb::TestColor16M() sl@0: { sl@0: INFO_PRINTF1(_L("Color16M")); sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TInt color16M = ((value & 0xff0000) >> 16) | (value & 0x00ff00) | ((value & 0x0000ff) << 16); sl@0: TRgb generatedColor = TRgb::Color16M(color16M); sl@0: TEST(color == generatedColor); sl@0: TEST(color.Color16M() == color16M); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 16MU colour set sl@0: sl@0: Cycle through each Color16MU colour & compare the TRgb value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Color16MU TRgb value against that produced by the algorithm sl@0: sl@0: Confirm the conversion from index value to 16MU colour value & back again produces identical value. sl@0: Confirm the algorithm used to produce 16MU colour set sl@0: */ sl@0: void CTRgb::TestColor16MU() sl@0: { sl@0: INFO_PRINTF1(_L("Color16MU")); sl@0: sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 31) sl@0: { sl@0: TRgb color(value); sl@0: TInt color16MU = ((value & 0xff0000) >> 16) | (value & 0x00ff00) | ((value & 0x0000ff) << 16); sl@0: TRgb generatedColor = TRgb::Color16MU(color16MU); sl@0: TEST(color == generatedColor); sl@0: TEST(color.Color16MU() == color16MU); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test 16MA colour set sl@0: sl@0: Cycle through each Color16MA colour & compare the TRgb value used to create the colour sl@0: against the index value retrieved from the colour palette. sl@0: Cycle through a series of RGB values & compare the Color16MA TRgb value against that produced by the algorithm sl@0: sl@0: Confirm the conversion from index value to 16MA colour value & back again produces identical value. sl@0: Confirm the algorithm used to produce 16MA colour set sl@0: */ sl@0: void CTRgb::TestColor16MA() sl@0: { sl@0: INFO_PRINTF1(_L("Color16MA")); sl@0: sl@0: for (TUint32 high = 0; high <= 0xffff; high += 51) sl@0: for (TUint32 low = 0; low <= 0xffff; low += 51) sl@0: { sl@0: TUint32 value = (high << 16) + low; // '+' operator has higher precedance than '<<' operator sl@0: TRgb color(value); sl@0: TInt color16MA = (0xff000000 - (value & 0xff000000)) | ((value & 0xff0000) >> 16) | (value & 0x00ff00) | ((value & 0x0000ff) << 16); sl@0: TRgb generatedColor = TRgb::Color16MA(color16MA); sl@0: TEST(color == generatedColor); sl@0: TEST(color.Color16MA() == color16MA); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Test TColor256Util sl@0: sl@0: Test functionality contained within TColor256Util. sl@0: sl@0: Confirm TColor256Util converts correctly between TRgb values & the corresponding index in the colour palette sl@0: sl@0: */ sl@0: void CTRgb::TestColor256Util() sl@0: { sl@0: INFO_PRINTF1(_L("TColor256Util")); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TColor256Util* util = new TColor256Util; sl@0: CPalette* palette = NULL; sl@0: TRAPD(err,palette = CPalette::NewDefaultL(EColor256)); sl@0: TEST(err==KErrNone); sl@0: util->Construct(*palette); sl@0: TEST(Mem::Compare((TUint8*)util,sizeof(TColor256Util),(TUint8*)DynamicPalette::DefaultColor256Util(),sizeof(TColor256Util))==0); sl@0: sl@0: TInt index; sl@0: for (index = 0; index < 256; index++) sl@0: { sl@0: TRgb color = TRgb::Color256(index); sl@0: TEST(util->Color256(index) == color); sl@0: TEST(util->Color256(color) == index); sl@0: } sl@0: sl@0: TRgb* rgbBuffer = new TRgb[256]; sl@0: TUint8* indexBuffer = new TUint8[256]; sl@0: for (index = 0; index < 256; index++) sl@0: rgbBuffer[index] = TRgb::Color256(index); sl@0: util->Color256(indexBuffer,rgbBuffer,256); sl@0: for (index = 0; index < 256; index++) sl@0: TEST(indexBuffer[index]==index); sl@0: sl@0: delete[] rgbBuffer; sl@0: delete[] indexBuffer; sl@0: delete palette; sl@0: delete util; sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: /** sl@0: Validate the PreMultiplied value and the Non PreMultiplied value with the expected values. sl@0: @param aAlpha Alpha value of the color. sl@0: @param aValue The value of the color channel(ie. one of Red,Green or Blue). sl@0: @param aPreMulVal The PreMutiplied color value for aValue. sl@0: @param aNonPreMulValue The Non PreMutiplied value for aValue sl@0: (i.e the value received by Non PreMutiplying aPreMulVal). sl@0: sl@0: */ sl@0: void CTRgb::ValidatePMAndNPM(TInt aAlpha, TInt aValue, TInt aPreMulVal, TInt aNonPreMulValue) sl@0: { sl@0: TInt expPreMulValue = (aValue*(aAlpha+1))/256; sl@0: TInt expNonPreMulValMin = (expPreMulValue * 255) / aAlpha; sl@0: TInt expNonPreMulValMax = expNonPreMulValMin + 1; sl@0: if (expNonPreMulValMax > 255) sl@0: { sl@0: expNonPreMulValMax = 255; sl@0: } sl@0: TEST(expPreMulValue == aPreMulVal); sl@0: TEST(expNonPreMulValMin <= aNonPreMulValue && expNonPreMulValMax >= aNonPreMulValue); sl@0: } sl@0: sl@0: /** sl@0: DEF103742 - Test the PreMultiply and Non PreMultiply conversion. sl@0: sl@0: Convert the color values into PreMultiplied color values and again back to sl@0: the Non PreMultiplied color values. sl@0: Compare the converted values with the expected values to validate the functionality. sl@0: sl@0: Confirm the PreMultiplied and Non PreMultiplied color values match with the expected values. sl@0: */ sl@0: void CTRgb::TestColor16MAP() sl@0: { sl@0: INFO_PRINTF1(_L("Color16MAP")); sl@0: for (TInt alpha = 0; alpha < 256; alpha += 51) sl@0: { sl@0: for (TUint32 value = 0; value <= 0x00ffffff; value += 0x1f1f) sl@0: { sl@0: TRgb color(value, alpha); sl@0: TUint pmColor = color.Color16MAP(); sl@0: TRgb npmColor = TRgb::Color16MAP(pmColor); sl@0: sl@0: TInt pmAlpha = (pmColor & 0xFF000000) >> 24; sl@0: sl@0: // These really must be right! sl@0: TEST(pmAlpha == alpha); sl@0: TEST(npmColor.Alpha() == alpha); sl@0: sl@0: // These definitely ought to be right sl@0: if (alpha == 0) // Full transparency, expect black sl@0: { sl@0: TEST(pmColor == 0); sl@0: TEST(npmColor.Internal() == 0); sl@0: } sl@0: else if (alpha == 255) // Full opacity, expect roundtrip sl@0: { sl@0: TEST(pmColor == color.Internal()); sl@0: TEST(npmColor == color); sl@0: } sl@0: else sl@0: { sl@0: // Most awkward cases: semi-transparency. sl@0: TInt pmRed = (pmColor & 0x00FF0000) >> 16; sl@0: TInt pmGreen = (pmColor & 0x0000FF00) >> 8; sl@0: TInt pmBlue = pmColor & 0xFF; sl@0: ValidatePMAndNPM(alpha, color.Red(), pmRed, npmColor.Red()); sl@0: ValidatePMAndNPM(alpha, color.Green(), pmGreen, npmColor.Green()); sl@0: ValidatePMAndNPM(alpha, color.Blue(), pmBlue, npmColor.Blue()); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: //-------------- sl@0: __CONSTRUCT_STEP__(Rgb)