How to programmatically edit iPhone accessibility settings during unit test?How to programmatically send SMS on the iPhone?How should I unit test threaded code?How can I develop for iPhone using a Windows development machine?How do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?Unit test naming best practicesJavaScript unit test tools for TDDWhat is Unit test, Integration Test, Smoke test, Regression Test?How can I make a UITextField move up when the keyboard is present - on starting to edit?
Which verb form to use with "с"
Should developer taking test phones home or put in office?
Are there any vegetarian astronauts?
Can ADFS connect to other SSO services?
Should I include salary information on my CV?
Abel-Jacobi map on symmetric product of genus 4 curve
C-152 carb heat on before landing in hot weather?
Require advice on power conservation for backpacking trip
Is adding a new player (or players) a DM decision, or a group decision?
Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback
Employer wants to use my work email account after I quit, is this legal under German law? Is this a GDPR waiver?
Using “sparkling” as a diminutive of “spark” in a poem
Could Sauron have read Tom Bombadil's mind if Tom had held the Palantir?
Does squid ink pasta bleed?
Does the posterior necessarily follow the same conditional dependence structure as the prior?
Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?
Unusual mail headers, evidence of an attempted attack. Have I been pwned?
Story-based adventure with functions and relationships
Impossible darts scores
What happens when I sacrifice a creature when my Teysa Karlov is on the battlefield?
STM Microcontroller burns every time
Why do some professors with PhDs leave their professorships to teach high school?
Is it damaging to turn off a small fridge for two days every week?
Analog is Obtuse!
How to programmatically edit iPhone accessibility settings during unit test?
How to programmatically send SMS on the iPhone?How should I unit test threaded code?How can I develop for iPhone using a Windows development machine?How do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?Unit test naming best practicesJavaScript unit test tools for TDDWhat is Unit test, Integration Test, Smoke test, Regression Test?How can I make a UITextField move up when the keyboard is present - on starting to edit?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
My application supports dynamic fonts. When user changes font size in settings (Settings > General > Accessibility > Larger Text
) and jump back to application then every label should be updated.
It is implemented by overriding UILabel's function
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
super.traitCollectionDidChange(previousTraitCollection)
guard previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory else return
let metrics: UIFontMetrics = UIFontMetrics(
forTextStyle: UIFont.TextStyle.body
)
font = metrics.scaledFont(for: font)
Now I need to test if other views react correctly to label's dynamic nature.
Specifically, I would like to have following unit test:
- Create view with label
- Get size of view
- Change system font to bigger
- Get size of view
- Compare if sizes changed
func testDynamicFont()
let v: MyView = MyView()
let oldSize: CGSize = v.intrinsicContentSize
??? What to do here? ???
let newSize: CGSize = v.intrinsicContentSize
XCTAssertNotEqual(
oldSize,
newSize,
"Size of view should adjust to new environment"
)
ios swift unit-testing
add a comment |
My application supports dynamic fonts. When user changes font size in settings (Settings > General > Accessibility > Larger Text
) and jump back to application then every label should be updated.
It is implemented by overriding UILabel's function
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
super.traitCollectionDidChange(previousTraitCollection)
guard previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory else return
let metrics: UIFontMetrics = UIFontMetrics(
forTextStyle: UIFont.TextStyle.body
)
font = metrics.scaledFont(for: font)
Now I need to test if other views react correctly to label's dynamic nature.
Specifically, I would like to have following unit test:
- Create view with label
- Get size of view
- Change system font to bigger
- Get size of view
- Compare if sizes changed
func testDynamicFont()
let v: MyView = MyView()
let oldSize: CGSize = v.intrinsicContentSize
??? What to do here? ???
let newSize: CGSize = v.intrinsicContentSize
XCTAssertNotEqual(
oldSize,
newSize,
"Size of view should adjust to new environment"
)
ios swift unit-testing
Does the below answer solves your problem?
– Anand
Mar 26 at 15:12
Yes it do. Thank you :)
– Pikacz
Mar 26 at 16:12
add a comment |
My application supports dynamic fonts. When user changes font size in settings (Settings > General > Accessibility > Larger Text
) and jump back to application then every label should be updated.
It is implemented by overriding UILabel's function
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
super.traitCollectionDidChange(previousTraitCollection)
guard previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory else return
let metrics: UIFontMetrics = UIFontMetrics(
forTextStyle: UIFont.TextStyle.body
)
font = metrics.scaledFont(for: font)
Now I need to test if other views react correctly to label's dynamic nature.
Specifically, I would like to have following unit test:
- Create view with label
- Get size of view
- Change system font to bigger
- Get size of view
- Compare if sizes changed
func testDynamicFont()
let v: MyView = MyView()
let oldSize: CGSize = v.intrinsicContentSize
??? What to do here? ???
let newSize: CGSize = v.intrinsicContentSize
XCTAssertNotEqual(
oldSize,
newSize,
"Size of view should adjust to new environment"
)
ios swift unit-testing
My application supports dynamic fonts. When user changes font size in settings (Settings > General > Accessibility > Larger Text
) and jump back to application then every label should be updated.
It is implemented by overriding UILabel's function
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
super.traitCollectionDidChange(previousTraitCollection)
guard previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory else return
let metrics: UIFontMetrics = UIFontMetrics(
forTextStyle: UIFont.TextStyle.body
)
font = metrics.scaledFont(for: font)
Now I need to test if other views react correctly to label's dynamic nature.
Specifically, I would like to have following unit test:
- Create view with label
- Get size of view
- Change system font to bigger
- Get size of view
- Compare if sizes changed
func testDynamicFont()
let v: MyView = MyView()
let oldSize: CGSize = v.intrinsicContentSize
??? What to do here? ???
let newSize: CGSize = v.intrinsicContentSize
XCTAssertNotEqual(
oldSize,
newSize,
"Size of view should adjust to new environment"
)
ios swift unit-testing
ios swift unit-testing
edited Mar 26 at 9:51
sourav.bh
4441 gold badge5 silver badges19 bronze badges
4441 gold badge5 silver badges19 bronze badges
asked Mar 25 at 10:31
PikaczPikacz
531 silver badge8 bronze badges
531 silver badge8 bronze badges
Does the below answer solves your problem?
– Anand
Mar 26 at 15:12
Yes it do. Thank you :)
– Pikacz
Mar 26 at 16:12
add a comment |
Does the below answer solves your problem?
– Anand
Mar 26 at 15:12
Yes it do. Thank you :)
– Pikacz
Mar 26 at 16:12
Does the below answer solves your problem?
– Anand
Mar 26 at 15:12
Does the below answer solves your problem?
– Anand
Mar 26 at 15:12
Yes it do. Thank you :)
– Pikacz
Mar 26 at 16:12
Yes it do. Thank you :)
– Pikacz
Mar 26 at 16:12
add a comment |
1 Answer
1
active
oldest
votes
You can increase the System Font size using below code.
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settings.launch()
settings.tables.staticTexts["General"].tap()
settings.tables.staticTexts["Accessibility"].tap()
settings.tables.staticTexts["Larger Text"].tap()
settings.sliders.element.adjust(toNormalizedSliderPosition: 0.7) // Increase as you need
To go back to your own app,
let yourapp = XCUIApplication(bundleIdentifier: "com.xxx.yourappbundleid")
yourapp.activate()
Tested in iPhone (Real Device), iOS 12.1.4
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335786%2fhow-to-programmatically-edit-iphone-accessibility-settings-during-unit-test%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can increase the System Font size using below code.
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settings.launch()
settings.tables.staticTexts["General"].tap()
settings.tables.staticTexts["Accessibility"].tap()
settings.tables.staticTexts["Larger Text"].tap()
settings.sliders.element.adjust(toNormalizedSliderPosition: 0.7) // Increase as you need
To go back to your own app,
let yourapp = XCUIApplication(bundleIdentifier: "com.xxx.yourappbundleid")
yourapp.activate()
Tested in iPhone (Real Device), iOS 12.1.4
add a comment |
You can increase the System Font size using below code.
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settings.launch()
settings.tables.staticTexts["General"].tap()
settings.tables.staticTexts["Accessibility"].tap()
settings.tables.staticTexts["Larger Text"].tap()
settings.sliders.element.adjust(toNormalizedSliderPosition: 0.7) // Increase as you need
To go back to your own app,
let yourapp = XCUIApplication(bundleIdentifier: "com.xxx.yourappbundleid")
yourapp.activate()
Tested in iPhone (Real Device), iOS 12.1.4
add a comment |
You can increase the System Font size using below code.
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settings.launch()
settings.tables.staticTexts["General"].tap()
settings.tables.staticTexts["Accessibility"].tap()
settings.tables.staticTexts["Larger Text"].tap()
settings.sliders.element.adjust(toNormalizedSliderPosition: 0.7) // Increase as you need
To go back to your own app,
let yourapp = XCUIApplication(bundleIdentifier: "com.xxx.yourappbundleid")
yourapp.activate()
Tested in iPhone (Real Device), iOS 12.1.4
You can increase the System Font size using below code.
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settings.launch()
settings.tables.staticTexts["General"].tap()
settings.tables.staticTexts["Accessibility"].tap()
settings.tables.staticTexts["Larger Text"].tap()
settings.sliders.element.adjust(toNormalizedSliderPosition: 0.7) // Increase as you need
To go back to your own app,
let yourapp = XCUIApplication(bundleIdentifier: "com.xxx.yourappbundleid")
yourapp.activate()
Tested in iPhone (Real Device), iOS 12.1.4
edited Mar 26 at 15:11
answered Mar 25 at 16:06
AnandAnand
1,13712 silver badges20 bronze badges
1,13712 silver badges20 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335786%2fhow-to-programmatically-edit-iphone-accessibility-settings-during-unit-test%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does the below answer solves your problem?
– Anand
Mar 26 at 15:12
Yes it do. Thank you :)
– Pikacz
Mar 26 at 16:12