## 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 omni.kit.test
import platform
import unittest

import omni.kit.app
from omni.kit.test.async_unittest import AsyncTestCase
import omni.usd

from omni.kit import ui_test

from omni.kit.test_suite.helpers import open_stage, get_test_data_path, select_prims, wait_stage_loading, arrange_windows


class SelectBoundObjectsViewport(AsyncTestCase):
    # Before running each test
    async def setUp(self):
        await arrange_windows()
        await open_stage(get_test_data_path(__name__, "bound_shapes.usda"))

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


    DATA = [
        ("/World/Looks/OmniPBR", {"/World/Cone", "/World/Cylinder"}),
        ("/World/Looks/OmniGlass", {"/World/Cube", "/World/Sphere"}),
    ]

    async def test_l1_select_bound_objects_viewport(self):
        usd_context = omni.usd.get_context()
        for to_select, to_verify in self.DATA:
            # select prim
            await select_prims([to_select])

            # wait for material to load & UI to refresh
            await wait_stage_loading()

            # right click on viewport
            await ui_test.find("Viewport").right_click()

            # click context menu "Select Bound Objects"
            await ui_test.select_context_menu("Select Bound Objects")

            # veirfy new selection
            selected = usd_context.get_selection().get_selected_prim_paths()
            self.assertSetEqual(set(selected), to_verify)
