# Path: pywinauto/findbestmatch.py
# class MatchError(IndexError):
# class UniqueDict(dict):
#     def __init__(self, items = None, tofind = ''):
# def _get_match_ratios(texts, match_against):
# def find_best_match(search_text, item_texts, items, limit_ratio = .5):
# def _cut_at_tab(text):
# def _cut_at_eol(text):
# def _clean_non_chars(text):
# def is_above_or_to_left(ref_control, other_ctrl):
# def get_non_text_control_name(ctrl, controls, text_ctrls):
# def get_control_names(control, allcontrols, textcontrols):
#     def __setitem__(self, text, item):
#     def find_best_matches(
#         self,
#         search_text,
#         clean = False,
#         ignore_case = False):
# def build_unique_dict(controls):
# def find_best_control_matches(search_text, controls):
# 
# Path: pywinauto/windows/win32structures.py
# BOOL = wintypes.BOOL
# BYTE = wintypes.BYTE
# CHAR = c_char
# DWORD = wintypes.DWORD
# HANDLE = wintypes.HANDLE
# HBITMAP = HANDLE
# LONG = wintypes.LONG
# LPVOID = wintypes.LPVOID
# PVOID = c_void_p
# UINT = wintypes.UINT
# WCHAR = wintypes.WCHAR
# WORD = wintypes.WORD
# LRESULT = wintypes.LPARAM
# COLORREF = wintypes.COLORREF
# LPBYTE = POINTER(BYTE)
# LPWSTR = c_size_t #POINTER(WCHAR)
# DWORD_PTR = UINT_PTR = ULONG_PTR = c_size_t
# PDWORD_PTR = POINTER(DWORD_PTR)
#     INT_PTR = LONG_PTR = c_longlong
#     INT_PTR = LONG_PTR = c_long
# HINSTANCE = LONG_PTR #LONG
# HMENU = LONG_PTR #LONG
# HBRUSH = wintypes.HBRUSH  # LONG_PTR #LONG
# HTREEITEM = LONG_PTR #LONG
# HWND = wintypes.HWND
# LPARAM = wintypes.LPARAM
# WPARAM = wintypes.WPARAM
# class POINT(wintypes.POINT, PointIteratorMixin, StructureMixIn):
# class RECT(wintypes.RECT, RectExtMixin, StructureMixIn):
# class SETTEXTEX(Structure):
# class LVCOLUMNW(Structure):
# class LVCOLUMNW32(Structure):
# class LVITEMW(Structure):
# class LVITEMW32(Structure):
# class TVITEMW(Structure):
# class TVITEMW32(Structure):
# class NMHDR(Structure):
# class NMTVDISPINFOW(Structure):
# class LOGFONTW(Structure):
# class TEXTMETRICW(Structure):
# class NONCLIENTMETRICSW(Structure):
# class LOGBRUSH(Structure):
# class MENUITEMINFOW(Structure):
# class MENUBARINFO(Structure):
# class MSG(Structure):
# class TOOLINFOW(Structure):
# class HDITEMW(Structure):
# class COMBOBOXEXITEMW(Structure):
# class TCITEMHEADERW(Structure):
# class TCITEMW(Structure):
# class TBBUTTONINFOW(Structure):
# class TBBUTTONINFOW32(Structure):
#     class TBBUTTON(Structure):
#     class TBBUTTON(Structure):
# class TBBUTTON32(Structure):
# class REBARBANDINFOW(Structure):
# class SECURITY_ATTRIBUTES(Structure):
# class STARTUPINFOW(Structure):
# class PROCESS_INFORMATION(Structure):
# class NMLISTVIEW(Structure):
# class NMMOUSE(Structure):
# class MOUSEINPUT(Structure):
# class KEYBDINPUT(Structure):
# class HARDWAREINPUT(Structure):
# class UNION_INPUT_STRUCTS(Union):
# class INPUT(Structure):
# class NMUPDOWN(Structure):
# class GUITHREADINFO(Structure):
# class MENUINFO(Structure):
# class NMTTDISPINFOW(Structure):
# class WINDOWPLACEMENT(Structure):
# class LVHITTESTINFO(Structure):
# class TVHITTESTINFO(Structure):
# class LOGFONTA(Structure):
# class GV_ITEM(Structure):
# class SYSTEMTIME(Structure):
# class MCHITTESTINFO(Structure):
# class KBDLLHOOKSTRUCT(Structure):
# class MSLLHOOKSTRUCT(Structure):
#     def __init__(self, other=0, top=0, right=0, bottom=0):
#     def __str__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __str__(self):


import unittest
import os.path
import sys
from pywinauto import findbestmatch
from pywinauto.windows import win32structures

# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Tests for findbestmatch.py"""


test_path = os.path.split(__file__)[0]

sys.path.append(".")


class TestFindBestMatch(unittest.TestCase):

    def setUp(self):
        """load the test strings"""
        self.strings = open(os.path.join(test_path, "testtext.txt"), "rb").readlines()
        self.strings = (line.decode('utf-8')[:-1] for line in self.strings)

    def testclean_text_1(self):
        "Test for _clean_non_chars (alphanumeric symbols)"
        s = "nothingremovedhere"
        result =  findbestmatch._clean_non_chars(s)
        self.assertEqual(s, result)

    def testclean_text_2(self):
        "Test for _clean_non_chars (special symbols)"
        s = "#$%#^$%&**"

# Path: pywinauto/findbestmatch.py
# class MatchError(IndexError):
# class UniqueDict(dict):
#     def __init__(self, items = None, tofind = ''):
# def _get_match_ratios(texts, match_against):
# def find_best_match(search_text, item_texts, items, limit_ratio = .5):
# def _cut_at_tab(text):
# def _cut_at_eol(text):
# def _clean_non_chars(text):
# def is_above_or_to_left(ref_control, other_ctrl):
# def get_non_text_control_name(ctrl, controls, text_ctrls):
# def get_control_names(control, allcontrols, textcontrols):
#     def __setitem__(self, text, item):
#     def find_best_matches(
#         self,
#         search_text,
#         clean = False,
#         ignore_case = False):
# def build_unique_dict(controls):
# def find_best_control_matches(search_text, controls):
# 
# Path: pywinauto/windows/win32structures.py
# BOOL = wintypes.BOOL
# BYTE = wintypes.BYTE
# CHAR = c_char
# DWORD = wintypes.DWORD
# HANDLE = wintypes.HANDLE
# HBITMAP = HANDLE
# LONG = wintypes.LONG
# LPVOID = wintypes.LPVOID
# PVOID = c_void_p
# UINT = wintypes.UINT
# WCHAR = wintypes.WCHAR
# WORD = wintypes.WORD
# LRESULT = wintypes.LPARAM
# COLORREF = wintypes.COLORREF
# LPBYTE = POINTER(BYTE)
# LPWSTR = c_size_t #POINTER(WCHAR)
# DWORD_PTR = UINT_PTR = ULONG_PTR = c_size_t
# PDWORD_PTR = POINTER(DWORD_PTR)
#     INT_PTR = LONG_PTR = c_longlong
#     INT_PTR = LONG_PTR = c_long
# HINSTANCE = LONG_PTR #LONG
# HMENU = LONG_PTR #LONG
# HBRUSH = wintypes.HBRUSH  # LONG_PTR #LONG
# HTREEITEM = LONG_PTR #LONG
# HWND = wintypes.HWND
# LPARAM = wintypes.LPARAM
# WPARAM = wintypes.WPARAM
# class POINT(wintypes.POINT, PointIteratorMixin, StructureMixIn):
# class RECT(wintypes.RECT, RectExtMixin, StructureMixIn):
# class SETTEXTEX(Structure):
# class LVCOLUMNW(Structure):
# class LVCOLUMNW32(Structure):
# class LVITEMW(Structure):
# class LVITEMW32(Structure):
# class TVITEMW(Structure):
# class TVITEMW32(Structure):
# class NMHDR(Structure):
# class NMTVDISPINFOW(Structure):
# class LOGFONTW(Structure):
# class TEXTMETRICW(Structure):
# class NONCLIENTMETRICSW(Structure):
# class LOGBRUSH(Structure):
# class MENUITEMINFOW(Structure):
# class MENUBARINFO(Structure):
# class MSG(Structure):
# class TOOLINFOW(Structure):
# class HDITEMW(Structure):
# class COMBOBOXEXITEMW(Structure):
# class TCITEMHEADERW(Structure):
# class TCITEMW(Structure):
# class TBBUTTONINFOW(Structure):
# class TBBUTTONINFOW32(Structure):
#     class TBBUTTON(Structure):
#     class TBBUTTON(Structure):
# class TBBUTTON32(Structure):
# class REBARBANDINFOW(Structure):
# class SECURITY_ATTRIBUTES(Structure):
# class STARTUPINFOW(Structure):
# class PROCESS_INFORMATION(Structure):
# class NMLISTVIEW(Structure):
# class NMMOUSE(Structure):
# class MOUSEINPUT(Structure):
# class KEYBDINPUT(Structure):
# class HARDWAREINPUT(Structure):
# class UNION_INPUT_STRUCTS(Union):
# class INPUT(Structure):
# class NMUPDOWN(Structure):
# class GUITHREADINFO(Structure):
# class MENUINFO(Structure):
# class NMTTDISPINFOW(Structure):
# class WINDOWPLACEMENT(Structure):
# class LVHITTESTINFO(Structure):
# class TVHITTESTINFO(Structure):
# class LOGFONTA(Structure):
# class GV_ITEM(Structure):
# class SYSTEMTIME(Structure):
# class MCHITTESTINFO(Structure):
# class KBDLLHOOKSTRUCT(Structure):
# class MSLLHOOKSTRUCT(Structure):
#     def __init__(self, other=0, top=0, right=0, bottom=0):
#     def __str__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __str__(self):


# Path: pywinauto/unittests/test_findbestmatch.py
import unittest
import os.path
import sys
from pywinauto import findbestmatch
from pywinauto.windows import win32structures

# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Tests for findbestmatch.py"""


test_path = os.path.split(__file__)[0]

sys.path.append(".")


class TestFindBestMatch(unittest.TestCase):

    def setUp(self):
        """load the test strings"""
        self.strings = open(os.path.join(test_path, "testtext.txt"), "rb").readlines()
        self.strings = (line.decode('utf-8')[:-1] for line in self.strings)

    def testclean_text_1(self):
        "Test for _clean_non_chars (alphanumeric symbols)"
        s = "nothingremovedhere"
        result =  findbestmatch._clean_non_chars(s)
        self.assertEqual(s, result)

    def testclean_text_2(self):
        "Test for _clean_non_chars (special symbols)"
        s = "#$%#^$%&**"

        result =  findbestmatch._clean_non_chars(s)
