/core/externals/google-toolbox-for-mac/iPhone/GTMFadeTruncatingLabelTest.m

http://macfuse.googlecode.com/ · Objective C · 67 lines · 40 code · 9 blank · 18 comment · 0 complexity · 91703453fef0495cd5223f640aa47b0f MD5 · raw file

  1. //
  2. // GTMFadeTruncatingLabelTest.m
  3. //
  4. // Copyright 2011 Google Inc.
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7. // use this file except in compliance with the License. You may obtain a copy
  8. // of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. // License for the specific language governing permissions and limitations under
  16. // the License.
  17. //
  18. #import "GTMNSObject+UnitTesting.h"
  19. #import "GTMSenTestCase.h"
  20. #import "GTMFadeTruncatingLabel.h"
  21. @interface GTMFadeTruncatingLabelTest : GTMTestCase
  22. @end
  23. @implementation GTMFadeTruncatingLabelTest
  24. - (void)testFadeTruncatingLabelRight {
  25. GTMFadeTruncatingLabel* label = [[[GTMFadeTruncatingLabel alloc]
  26. initWithFrame:CGRectMake(0, 0, 200, 25)]
  27. autorelease];
  28. label.text = @"A very long string that won't fit";
  29. GTMAssertObjectImageEqualToImageNamed(label,
  30. @"GTMFadeTruncatingLabelTest1",
  31. @"Mismatched image.");
  32. label.text = @"A short string";
  33. GTMAssertObjectImageEqualToImageNamed(label,
  34. @"GTMFadeTruncatingLabelTest2",
  35. @"Mismatched image.");
  36. // Dark background, light text.
  37. label.backgroundColor = [UIColor blackColor];
  38. [label setTextColor:[UIColor whiteColor]];
  39. label.text = @"A very long string that won't fit";
  40. GTMAssertObjectImageEqualToImageNamed(label,
  41. @"GTMFadeTruncatingLabelTest3",
  42. @"Mismatched image.");
  43. label.text = @"A short string";
  44. GTMAssertObjectImageEqualToImageNamed(label,
  45. @"GTMFadeTruncatingLabelTest4",
  46. @"Mismatched image.");
  47. }
  48. - (void)testFadeTruncatingLabelLeftAndRight {
  49. GTMFadeTruncatingLabel* label = [[[GTMFadeTruncatingLabel alloc]
  50. initWithFrame:CGRectMake(0, 0, 200, 25)]
  51. autorelease];
  52. label.truncateMode = GTMFadeTruncatingHeadAndTail;
  53. label.text = @"Fade on both left and right";
  54. GTMAssertObjectImageEqualToImageNamed(label,
  55. @"GTMFadeTruncatingLabelTest5",
  56. @"Mismatched image.");
  57. }
  58. @end