From d17eb6aeb9aed66c0639ffc8504da4a864f5e2c6 Mon Sep 17 00:00:00 2001
From: osamacis <mohammad.o@cisinlabs.com>
Date: Thu, 24 Nov 2022 19:26:59 +0530
Subject: [PATCH] Add test case for file manager opening and closing

---
 src/bitmessagekivy/tests/test_filemanager.py | 68 ++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 src/bitmessagekivy/tests/test_filemanager.py

diff --git a/src/bitmessagekivy/tests/test_filemanager.py b/src/bitmessagekivy/tests/test_filemanager.py
new file mode 100644
index 00000000..3a3b366e
--- /dev/null
+++ b/src/bitmessagekivy/tests/test_filemanager.py
@@ -0,0 +1,68 @@
+from .telenium_process import TeleniumTestProcess
+from .common import ordered
+
+
+class FileManagerOpening(TeleniumTestProcess):
+    """File-manager Opening Functionality Testing"""
+    @ordered
+    def test_open_file_manager(self):
+        """Opening and Closing File-manager"""
+        # Checking current Screen(Inbox screen)
+        self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox')
+        # Method to open side navbar
+        self.open_side_navbar()
+        # Click to open Address Dropdown
+        self.assertExists('//NavigationItem[0][@text=\"dropdown_nav_item\"]', timeout=2)
+        self.assertExists(
+            '//NavigationItem[0][@text=\"dropdown_nav_item\"]'
+            '/IdentitySpinner[@name=\"identity_dropdown\"]', timeout=1
+        )
+        # Check the state of dropdown
+        self.assertExists(
+            '//NavigationItem[0][@text=\"dropdown_nav_item\"]'
+            '/IdentitySpinner[@name=\"identity_dropdown\"][@is_open=false]', timeout=1
+        )
+        self.cli.wait(
+            '//NavigationItem[0][@text=\"dropdown_nav_item\"]'
+            '/IdentitySpinner[@name=\"identity_dropdown\"][@state=\"normal\"]', timeout=2
+        )
+        self.cli.wait_click(
+            '//NavigationItem[0][@text=\"dropdown_nav_item\"]'
+            '/IdentitySpinner[@name=\"identity_dropdown\"]', timeout=1
+        )
+        # Check the state of dropdown.
+        self.assertExists(
+            '//NavigationItem[0][@text=\"dropdown_nav_item\"]'
+            '/IdentitySpinner[@name=\"identity_dropdown\"][@is_open=true]', timeout=1
+        )
+        # List of addresses
+        addresses_in_dropdown = self.cli.getattr(
+            '//NavigationItem[0][@text=\"dropdown_nav_item\"]/IdentitySpinner[@values]', 'values'
+        )
+        # Checking the dropdown options are exists
+        self.assertGreaterEqual(len(self.cli.getattr(
+            '//MySpinnerOption[@text]', 'text')), len(addresses_in_dropdown)
+        )
+        # Selection of an address to set as a default address.
+        self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
+        # this is for scrolling Nav drawer
+        self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
+        # assert for checking scroll function
+        self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=5)
+        # checking state of Nav drawer
+        self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5)
+        # Checking File-manager icon
+        self.assertExists(
+            '//ContentNavigationDrawer//MDIconButton[1][@icon=\"file-image\"]',
+            timeout=5
+        )
+        # Clicking on file manager icon
+        self.cli.wait_click(
+            '//ContentNavigationDrawer//MDIconButton[1][@icon=\"file-image\"]',
+            timeout=5)
+        # Checking the state of file manager is it open or not
+        self.assertTrue(self.cli.execute('app.file_manager_open'))
+        # Closing the filemanager
+        self.cli.execute('app.exit_manager()')
+        # Checking the state of file manager is it closed or not
+        self.assertTrue(self.cli.execute('app.exit_manager()'))