## Copyright (c) 2021, NVIDIA CORPORATION.  All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto.  Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import pathlib
import sys
import unittest
import omni.kit.app
import omni.kit.test
import omni.ui as ui
from omni.kit import ui_test
from omni.ui.tests.test_base import OmniUiTest


class TestAboutWindowClipboard(OmniUiTest):
    # Before running each test
    async def setUp(self):
        await super().setUp()

    # After running each test
    async def tearDown(self):
        await super().tearDown()

    # @unittest.skipIf(sys.platform.startswith("linux"), "Pyperclip fails on some TeamCity agents")
    async def test_about_clipboard(self):

        class FakePluginImpl():
            def __init__(self, name):
                self.name = name

        class FakePlugin():
            def __init__(self, name):
                self.libPath = "Lib Path " + name
                self.impl = FakePluginImpl("Impl " + name)
                self.interfaces = "Interface " + name

        omni.kit.clipboard.copy("")

        about = omni.kit.window.about.get_instance()
        about.kit_version = "#Version#"
        about.nucleus_version = "#Nucleus Version#"
        about.client_library_version = "#Client Library Version#"
        about.app_name = "#App Name#"
        about.app_version = "#App Version#"
        about.usd_resolver_version = "#USD Resolver Version#"
        about.usd_version = "#USD Version#"
        about.mdlsdk_version = "#MDL SDK Version#"
        about_window = about.menu_show_about([FakePlugin("Test 1"), FakePlugin("Test 2"), FakePlugin("Test 3"), FakePlugin("Test 4")])

        await ui_test.find("About//Frame/**/Button[*].identifier=='copy_to_clipboard'").click(right_click=True)
        await ui_test.human_delay()

        clipboard = omni.kit.clipboard.paste()
        self.assertEqual(clipboard, "#App Name# #App Version#\nOmniverse Kit #Version#\nClient Library Version: #Client Library Version#\nUSD Resolver Version: #USD Resolver Version#\nUSD Version: #USD Version#\nMDL SDK Version: #MDL SDK Version#")
