Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for managing SpringBoard alerts manually #611

Merged
merged 4 commits into from
Mar 22, 2017

Conversation

jmoody
Copy link
Contributor

@jmoody jmoody commented Mar 22, 2017

Motivation

Completes:

Progress on:

  • Allow Users to Accept "Open In" Alerts TCFW 1081

API

# Control whether or not SpringBoard alerts are dismissed automatically or manually.
set_dismiss_springboard_alerts_automatically(true_or_false)

# Detecting and inspecting SpringBoard alerts
springboard_alert_visible?
springboard_alert
wait_for_springboard_alert
wait_for_no_springboard_alert

# Dismiss topmost SpringBoard alert by touching button with title.
dismiss_springboard_alert(button_title)

Test

Tested against changes in DeviceAgent:

  • Allow users to interact with SpringBoard alerts and control automatic dismissal #205
$ be cucumber -t @springboard_alerts

@meta
Feature: Meta Routes

  @springboard @springboard_alerts
  Scenario: SpringBoard alerts                                           
    Given the app has launched                                          
    Then I can tell DeviceAgent not to automatically dismiss SpringBoard alerts
    Then I can tell DeviceAgent to automatically dismiss SpringBoard alerts     

@simulator @springboard_alerts
Feature: Interacting with SpringBoard Alerts

  Background: Navigate to Alerts and Sheets page   
    Given the app has launched                     
    And I am looking at the Misc tab              
    And I am looking at the Alerts and Sheets page 

  @reset_device
  Scenario: Auto-dismiss contacts                       
    When DeviceAgent is dismissing alerts automatically 
    When I touch the Contacts row                       
    Then the Contacts Privacy alert appears        
    And the next query dismisses the alert           
    When I touch the Calendar row                       
    Then the Calendar Privacy alert appears        
    And the next gesture dismisses the alert       

  @reset_device
  Scenario: Dismiss Alerts Manually         
    When DeviceAgent is not dismissing alerts automatically
    When I touch the Reminders row                       
    Then the Reminders Privacy alert appears        
    And the next query does not dismiss the alert  
    And the next gesture does not dismiss the alert 
    But I can dismiss the SpringBoard alert by touching OK 

@jmoody jmoody added this to the 2.4.0 milestone Mar 22, 2017
@jmoody jmoody self-assigned this Mar 22, 2017
end

# @!visibility private
def dismiss_springboard_alerts_automatically

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a long history with ruby idioms, but with most languages in this case I'd expect an API to accept a parameter instead of have the parameter implicitly dictated by the method name:

dismiss_springboard_alerts_automatically(true);
dismissSpringboardAlertsAutomatically(true);
[self dismissSpringboardAlertsAutomatically:YES];

If you wanted to force more semantic clarity on the caller, maybe something like

set_springboard_alert_dismissal(SpringboardDismissal::MANUAL)

In my mind, if I were programming and I realized I wanted to change the state of springboard automatic dismissal, I'd assume I'm going to be _set_ting a state and thus would instinctively look for a method whose name was similar to set_<something> or otherwise more clearly implied a change of state.

If I'm not mistaken, ruby semantics would suggest at the very least that the method names, since they are changing state/have side effects, be dismiss_springboard_alerts_automatically! and dismiss_springboard_alerts_manually!, no?

A more clear approach in my opinion might be

enable_automatic_springboard_alert_dismissal!
disable_automatic_springboard_alert_dismissal!

Also, I think these two methods could be refactored - seems they only have a single variable differentiating their implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_

You are right, this is better - particularly at this API level.

!

Also correct.

When I implement the public API (in Calabash iOS), I want to use:

dismiss_springboard_alerts_automatically! 
dismiss_springboard_alerts_manually!

for clarity - there is absolutely no ambiguity.

On the other hand, maybe it would be best to use the set_ idiom for discoverability.

I am trying to avoid using the word dismissal in the API and in the documentation because I have a feeling (based on Gitter chats) that it confuses non-native English speakers.

Thanks.

@jmoody jmoody force-pushed the feature/support-manually-managing-SpringBoard-alerts branch from 0aba3bc to a988ccf Compare March 22, 2017 16:21
jmoody added 4 commits March 22, 2017 19:58
Route no longer returns a result key.  Instead it returns a hash
representation of the showing SpringBoard alert or an empty hash
if no alert is showing
@jmoody jmoody force-pushed the feature/support-manually-managing-SpringBoard-alerts branch from a988ccf to 95b305f Compare March 22, 2017 19:46
@jmoody jmoody modified the milestones: 2.4.0, 2.4.1 Mar 22, 2017
@jmoody jmoody merged commit 104b84f into develop Mar 22, 2017
@DragonClub
Copy link

jmoody Thanks always.

Thanks for the latest korean alert patch.

def dismiss_springboard_alert (button_title)
-> How can I use it?

Should DeviceAgent be modified?

I know that only client.rb has been updated.

Thanks for the quick reply.

@jmoody
Copy link
Contributor Author

jmoody commented Mar 23, 2017

@DragonClub

You will have to wait for run-loop 2.4.0 which needs to wait for Xcode 8.3.

@jmoody jmoody deleted the feature/support-manually-managing-SpringBoard-alerts branch March 23, 2017 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants