• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Copyright (C) 2022 The Android Open Source Project
2#
3#  Licensed under the Apache License, Version 2.0 (the "License");
4#  you may not use this file except in compliance with the License.
5#  You may obtain a copy of the License at
6#
7#       http://www.apache.org/licenses/LICENSE-2.0
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14
15"""CTS-V Nearby Mainline Fast Pair end-to-end test case: seeker show half sheet UI."""
16
17from test_helper import constants
18from test_helper import fast_pair_base_test
19
20# The model ID to simulate on provider side.
21PROVIDER_SIMULATOR_MODEL_ID = constants.DEFAULT_MODEL_ID
22# The public key to simulate as registered headsets.
23PROVIDER_SIMULATOR_ANTI_SPOOFING_KEY = constants.DEFAULT_ANTI_SPOOFING_KEY
24# The anti-spoof key device metadata JSON file for data provider at seeker side.
25PROVIDER_SIMULATOR_KDM_JSON_FILE = constants.DEFAULT_KDM_JSON_FILE
26
27# Time in seconds for events waiting.
28SETUP_TIMEOUT_SEC = constants.SETUP_TIMEOUT_SEC
29BECOME_DISCOVERABLE_TIMEOUT_SEC = constants.BECOME_DISCOVERABLE_TIMEOUT_SEC
30START_ADVERTISING_TIMEOUT_SEC = constants.START_ADVERTISING_TIMEOUT_SEC
31HALF_SHEET_POPUP_TIMEOUT_SEC = constants.HALF_SHEET_POPUP_TIMEOUT_SEC
32
33
34class SeekerShowHalfSheetTest(fast_pair_base_test.FastPairBaseTest):
35    """Fast Pair seeker show half sheet UI test."""
36
37    def setup_test(self) -> None:
38        super().setup_test()
39        self._provider.start_model_id_advertising(PROVIDER_SIMULATOR_MODEL_ID,
40                                                  PROVIDER_SIMULATOR_ANTI_SPOOFING_KEY)
41        self._provider.wait_for_discoverable_mode(BECOME_DISCOVERABLE_TIMEOUT_SEC)
42        self._provider.wait_for_advertising_start(START_ADVERTISING_TIMEOUT_SEC)
43        self._seeker.put_anti_spoof_key_device_metadata(PROVIDER_SIMULATOR_MODEL_ID,
44                                                        PROVIDER_SIMULATOR_KDM_JSON_FILE)
45        self._seeker.set_fast_pair_scan_enabled(True)
46
47    def teardown_test(self) -> None:
48        self._seeker.set_fast_pair_scan_enabled(False)
49        self._provider.teardown_provider_simulator()
50        self._seeker.dismiss_halfsheet()
51        super().teardown_test()
52
53    def test_seeker_show_half_sheet(self) -> None:
54        self._seeker.wait_and_assert_halfsheet_showed(
55            timeout_seconds=HALF_SHEET_POPUP_TIMEOUT_SEC,
56            expected_model_id=PROVIDER_SIMULATOR_MODEL_ID)
57