Tests: Make token field inset test create window under set theme

The test set a default theme with a content inset after -setUp had
created its window, so the token field inherited the theme lacking the
inset. It passed only because CPScrollView read the inset from the
default theme.

The test now creates its window under the theme it sets
and verifies that the token scroll view has that theme.
This commit is contained in:
David Richardson committed 2026-12-03 11:52:39 -06:00
1 parent 1c7b9af209
commit 45d895323d
1 file changed
+11 -2
+11 -2
View File
@@ -74,9 +74,18 @@
try
{
var tokenField = [[CPTokenField alloc] initWithFrame:CGRectMake(10, 10, 100, 28)];
/*
2026-12-03: the token field was added to the window from -setUp, which was made
before the default theme changed and so has the theme without the inset. The
test passed only because the scroll view read its inset from the default theme,
not from its own. The window is now made under the theme with the inset, so the
token field inherits that theme.
*/
var window = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1024.0, 768.0) styleMask:CPWindowNotSizable],
tokenField = [[CPTokenField alloc] initWithFrame:CGRectMake(10, 10, 100, 28)];
[[_theWindow contentView] addSubview:tokenField];
[[window contentView] addSubview:tokenField];
[self assertTrue:[tokenField._tokenScrollView theme] === theme message:@"precondition: the token scroll view has the theme with the inset"];
[tokenField setNeedsLayout];
[tokenField layoutIfNeeded];