#    Copyright 2014-2016 ARM Limited
#
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
#

import os

from wlauto.exceptions import ValidationError
from wlauto.utils.types import list_of_strings

description = '''

Test description:

1. Open a local file on the device
2. Gestures test:
2.1. Swipe down across the central 50% of the screen in 200 x 5ms steps
2.2. Swipe up across the central 50% of the screen in 200 x 5ms steps
2.3. Swipe right from the edge of the screen in 50 x 5ms steps
2.4. Swipe left from the edge of the screen  in 50 x 5ms steps
2.5. Pinch out 50% in 100 x 5ms steps
2.6. Pinch In 50% in 100 x 5ms steps
3. Search test:
Search document_name for each string in the search_string_list
4. Close the document

Known working APK version: 16.1
'''

default_search_strings = [
'The quick brown fox jumps over the lazy dog',
'TEST_SEARCH_STRING',
]

parameters = [
Parameter('document_name', kind=str, default="uxperf_test_doc.pdf",
description='''
The document name to use for the Gesture and Search test.
'''),
Parameter('search_string_list', kind=list_of_strings, default=default_search_strings,
constraint=lambda x: len(x) > 0,
description='''
For each string in the list, a document search is performed
using the string as the search term. At least one must be
provided.
'''),
]

def __init__(self, device, **kwargs):
self.deployable_assets = [self.document_name]
# Adobe only looks for local files in a specific path

def validate(self):
self.uiauto_params['filename'] = self.document_name
self.uiauto_params['search_string_list'] = self.search_string_list
# Only accept certain file formats
if os.path.splitext(self.document_name.lower())[1] not in ['.pdf']:
raise ValidationError('{} must be a PDF file'.format(self.document_name))

[docs]    def setup(self, context):