class TestCalendarMonthViewSelectEventAccessibility(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.event_title = 'title'
        self.event_location = 'location'

        self.calendar = Calendar(self.marionette)
        self.calendar.launch()

        new_event = self.calendar.a11y_click_add_event_button()

        # create a new event
        new_event.a11y_fill_event_title(self.event_title)
        new_event.a11y_fill_event_location(self.event_location)

        new_event.a11y_click_save_event()

        self.calendar.wait_for_events(1)

    def test_a11y_calendar_month_view_select_event(self):

        event = self.calendar.event(self.event_title)
        # Make sure that the title and the location are correct
        self.assertEquals(event.title, self.event_title)
        self.assertEquals(event.location, self.event_location)

        event_detail = event.a11y_click()

        # Make sure that the title and the location correspond to the selected event.
        # Note: title and location are populated asynchronously
        Wait(self.marionette).until(
            lambda m: self.event_title == event_detail.title)
        Wait(self.marionette).until(
            lambda m: self.event_location == event_detail.location)
class TestCalendarMonthViewSelectEventAccessibility(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.event_title = "title"
        self.event_location = "location"

        self.calendar = Calendar(self.marionette)
        self.calendar.launch()

        new_event = self.calendar.a11y_click_add_event_button()

        # create a new event
        new_event.a11y_fill_event_title(self.event_title)
        new_event.a11y_fill_event_location(self.event_location)

        new_event.a11y_click_save_event()

        self.calendar.wait_for_events(1)

    def test_a11y_calendar_month_view_select_event(self):

        event = self.calendar.event(self.event_title)
        # Make sure that the title and the location are correct
        self.assertEquals(event.title, self.event_title)
        self.assertEquals(event.location, self.event_location)

        event_detail = event.a11y_click()

        # Make sure that the title and the location correspond to the selected event.
        # Note: title and location are populated asynchronously
        Wait(self.marionette).until(lambda m: self.event_title == event_detail.title)
        Wait(self.marionette).until(lambda m: self.event_location == event_detail.location)
class TestCalendarViewsVisibilityAccessibility(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        self.calendar = Calendar(self.marionette)
        self.calendar.launch()

        self.views = {
            'time_views': self.marionette.find_element(*self.calendar._time_views_locator),
            'current_day': self.marionette.find_element(
                *self.calendar._current_months_day_locator),
            'month': self.marionette.find_element(
                *self.calendar._current_monthly_calendar_locator),
            'day': self.marionette.find_element(*self.calendar._day_view_locator),
            'week': self.marionette.find_element(*self.calendar._week_view_locator),
            'settings': self.marionette.find_element(*self.calendar._settings_locator),
            'advanced_settings': self.marionette.find_element(
                *self.calendar._advanced_settings_view_locator),
            'modify_event': self.marionette.find_element(*self.calendar._modify_event_view_locator),
            'event': self.marionette.find_element(*self.calendar._event_view_locator),
            'create_account': self.marionette.find_element(
                *self.calendar._create_account_view_locator),
            'modify_account': self.marionette.find_element(
                *self.calendar._modify_account_view_locator)
        }

        self.event_title = 'title'
        new_event = self.calendar.a11y_click_add_event_button()
        # create a new event
        new_event.a11y_fill_event_title(self.event_title)
        new_event.a11y_click_save_event()
        self.calendar.wait_for_events(1)

    def test_a11y_calendar_views_visibility(self):

        def test_a11y_visible(*visible):
            for key, view in self.views.iteritems():
                if key in visible:
                    self.assertTrue(self.accessibility.is_visible(view))
                else:
                    self.assertTrue(self.accessibility.is_hidden(view))

        # Default
        test_a11y_visible('time_views', 'current_day', 'month')

        # Settings
        self.calendar.a11y_click_settings()
        test_a11y_visible('settings')

        # Advanced settings
        self.accessibility.click(self.marionette.find_element(
            *self.calendar.settings._advanced_settings_button_locator))
        test_a11y_visible('advanced_settings')

        # Create account
        self.accessibility.click(self.marionette.find_element(
            *self.calendar._create_account_button_locator))
        test_a11y_visible('create_account')

        # Modify account
        self.accessibility.click(self.calendar.account('caldav'))
        test_a11y_visible('modify_account')

        # Create account
        self.calendar.a11y_click_modify_account_back()
        test_a11y_visible('create_account')

        # Advanced settings
        self.calendar.a11y_click_create_account_back()
        test_a11y_visible('advanced_settings')

        # Settings
        self.accessibility.click(self.marionette.find_element(
            *self.calendar._advanced_settings_done_button_locator))
        test_a11y_visible('settings')

        # Default
        self.calendar.a11y_click_close_settings()
        test_a11y_visible('time_views', 'current_day', 'month')

        # Week
        self.calendar.a11y_click_week_display_button()
        test_a11y_visible('time_views', 'week')

        # Day
        self.calendar.a11y_click_day_display_button()
        test_a11y_visible('time_views', 'day')

        # Month
        self.calendar.a11y_click_month_display_button()
        test_a11y_visible('time_views', 'current_day', 'month')

        # New event
        new_event = self.calendar.a11y_click_add_event_button()
        test_a11y_visible('modify_event')

        # Month
        new_event.a11y_click_close_button()
        test_a11y_visible('time_views', 'current_day', 'month')

        # View event
        event = self.calendar.event(self.event_title)
        event.a11y_click()
        test_a11y_visible('event')
class TestCalendarViewsVisibilityAccessibility(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.calendar = Calendar(self.marionette)
        self.calendar.launch()

        self.views = {
            'time_views':
            self.marionette.find_element(*self.calendar._time_views_locator),
            'current_day':
            self.marionette.find_element(
                *self.calendar._current_months_day_locator),
            'month':
            self.marionette.find_element(
                *self.calendar._current_monthly_calendar_locator),
            'day':
            self.marionette.find_element(*self.calendar._day_view_locator),
            'week':
            self.marionette.find_element(*self.calendar._week_view_locator),
            'settings':
            self.marionette.find_element(*self.calendar._settings_locator),
            'advanced_settings':
            self.marionette.find_element(
                *self.calendar._advanced_settings_view_locator),
            'modify_event':
            self.marionette.find_element(
                *self.calendar._modify_event_view_locator),
            'event':
            self.marionette.find_element(*self.calendar._event_view_locator)
        }

        self.event_title = 'title'
        new_event = self.calendar.a11y_click_add_event_button()
        # create a new event
        new_event.a11y_fill_event_title(self.event_title)
        new_event.a11y_click_save_event()
        self.calendar.wait_for_events(1)

    def test_a11y_calendar_views_visibility(self):
        def test_a11y_visible(*visible):
            for key, view in self.views.iteritems():
                if key in visible:
                    self.assertTrue(self.accessibility.is_visible(view))
                else:
                    self.assertTrue(self.accessibility.is_hidden(view))

        # Default
        test_a11y_visible('time_views', 'current_day', 'month')

        # Settings
        self.calendar.a11y_click_settings()
        test_a11y_visible('settings')

        # Advanced settings
        self.accessibility.click(
            self.marionette.find_element(
                *self.calendar.settings._advanced_settings_button_locator))
        test_a11y_visible('advanced_settings')

        # Settings
        self.accessibility.click(
            self.marionette.find_element(
                *self.calendar._advanced_settings_done_button_locator))
        test_a11y_visible('settings')

        # Default
        self.calendar.a11y_click_close_settings()
        test_a11y_visible('time_views', 'current_day', 'month')

        # Week
        self.calendar.a11y_click_week_display_button()
        test_a11y_visible('time_views', 'week')

        # Day
        self.calendar.a11y_click_day_display_button()
        test_a11y_visible('time_views', 'day')

        # Month
        self.calendar.a11y_click_month_display_button()
        test_a11y_visible('time_views', 'current_day', 'month')

        # New event
        new_event = self.calendar.a11y_click_add_event_button()
        test_a11y_visible('modify_event')

        # Month
        new_event.a11y_click_close_button()
        test_a11y_visible('time_views', 'current_day', 'month')

        # View event
        event = self.calendar.event(self.event_title)
        event.a11y_click()
        test_a11y_visible('event')