summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorBoris Dušek <me@dusek.me>2015-02-08 21:35:11 +0100
committerBoris Dušek <me@dusek.me>2015-03-25 09:48:35 +0000
commitc37f2e8e45a48ed3912ecaf3d69ccd71691fd2b0 (patch)
tree8b88289e09b57ed5b0498d000a4224d03c02df49 /tests/auto/other
parentda3dbc45f3d698d74bbc1f0b84d0f840193701cc (diff)
Add string range tests to qaccessibilitymac
Change-Id: I099502d4948194d934ace1fabc5e3ce14f663eb9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
index 9573d26bd2..a182fc27d5 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
@@ -420,7 +420,27 @@ bool testLineEdit()
EXPECT(lineEdit != nil);
TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEdit];
- EXPECT([[le value] isEqualToString:@"a11y test QLineEdit"]);
+ NSString *value = @"a11y test QLineEdit";
+ EXPECT([le.value isEqualToString:value]);
+ EXPECT(value.length <= NSIntegerMax);
+ EXPECT(le.numberOfCharacters == static_cast<NSInteger>(value.length));
+ const NSRange ranges[] = {
+ { 0, 0},
+ { 0, 1},
+ { 0, 5},
+ { 5, 0},
+ { 5, 1},
+ { 0, value.length},
+ { value.length, 0},
+ };
+ for (size_t i = 0; i < sizeof(ranges)/sizeof(ranges[0]); ++i) {
+ NSRange range = ranges[i];
+ NSString *expectedSubstring = [value substringWithRange:range];
+ NSString *actualSubstring = [le stringForRange:range];
+ NSString *actualAttributedSubstring = [le attributedStringForRange:range].string;
+ EXPECT([actualSubstring isEqualTo:expectedSubstring]);
+ EXPECT([actualAttributedSubstring isEqualTo:expectedSubstring]);
+ }
return true;
}