# Path: android_env/components/app_screen_checker.py
# class DumpsysNode():
# class AppScreenChecker():
#   class Outcome(enum.IntEnum):
#   def __init__(self, data: Optional[str] = None):
#   def data(self) -> str:
#   def children(self) -> List['DumpsysNode']:
#   def find_child(self,
#                  predicate: Callable[['DumpsysNode'], bool],
#                  max_levels: int = 0) -> Optional['DumpsysNode']:
#   def __repr__(self):
#   def print_tree(self, indent: int = 2):
# def build_tree_from_dumpsys_output(dumpsys_output: str) -> DumpsysNode:
# def matches_path(dumpsys_activity_output: str,
#                  expected_view_hierarchy_path: Sequence[Pattern[str]],
#                  max_levels: int = 0) -> bool:
#     def regex_predicate(node, expr=regex):
#   def __init__(self,
#                adb_controller: adb_control.AdbController,
#                expected_app_screen: task_pb2.AppScreen):
#   def matches_current_app_screen(self) -> enum.IntEnum:
#     SUCCESS = 0
#     EMPTY_EXPECTED_ACTIVITY = 1
#     FAILED_ACTIVITY_EXTRACTION = 2
#     UNEXPECTED_ACTIVITY = 3
#     UNEXPECTED_VIEW_HIERARCHY = 4
# 
# Path: android_env/components/dumpsys_thread.py
# class DumpsysThread(thread_function.ThreadFunction):
#   class Signal(enum.IntEnum):
#     FETCH_DUMPSYS = 0
#     USER_EXITED_ACTIVITY = 1
#     USER_EXITED_VIEW_HIERARCHY = 2
#     OK = 3
#     DID_NOT_CHECK = 4
#   def __init__(
#       self,
#       app_screen_checker: AppScreenChecker,
#       check_frequency: int,
#       max_failed_current_activity: int,
#       block_input: bool,
#       block_output: bool,
#       name: str = 'dumpsys',
#   ):
#   def main(self):


from absl.testing import absltest
from android_env.components import app_screen_checker as screen_checker
from android_env.components import dumpsys_thread
import mock
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for android_env.components.dumpsys_thread."""




class DumpsysThreadTest(absltest.TestCase):

  def setUp(self):
    super().setUp()
    self._dumpsys_thread = dumpsys_thread.DumpsysThread(
        app_screen_checker=mock.create_autospec(
            screen_checker.AppScreenChecker),
        check_frequency=1,
        max_failed_current_activity=5,
        block_input=True,
        block_output=True)

  def test_unexpected_activity(self):

# Path: android_env/components/app_screen_checker.py
# class DumpsysNode():
# class AppScreenChecker():
#   class Outcome(enum.IntEnum):
#   def __init__(self, data: Optional[str] = None):
#   def data(self) -> str:
#   def children(self) -> List['DumpsysNode']:
#   def find_child(self,
#                  predicate: Callable[['DumpsysNode'], bool],
#                  max_levels: int = 0) -> Optional['DumpsysNode']:
#   def __repr__(self):
#   def print_tree(self, indent: int = 2):
# def build_tree_from_dumpsys_output(dumpsys_output: str) -> DumpsysNode:
# def matches_path(dumpsys_activity_output: str,
#                  expected_view_hierarchy_path: Sequence[Pattern[str]],
#                  max_levels: int = 0) -> bool:
#     def regex_predicate(node, expr=regex):
#   def __init__(self,
#                adb_controller: adb_control.AdbController,
#                expected_app_screen: task_pb2.AppScreen):
#   def matches_current_app_screen(self) -> enum.IntEnum:
#     SUCCESS = 0
#     EMPTY_EXPECTED_ACTIVITY = 1
#     FAILED_ACTIVITY_EXTRACTION = 2
#     UNEXPECTED_ACTIVITY = 3
#     UNEXPECTED_VIEW_HIERARCHY = 4
# 
# Path: android_env/components/dumpsys_thread.py
# class DumpsysThread(thread_function.ThreadFunction):
#   class Signal(enum.IntEnum):
#     FETCH_DUMPSYS = 0
#     USER_EXITED_ACTIVITY = 1
#     USER_EXITED_VIEW_HIERARCHY = 2
#     OK = 3
#     DID_NOT_CHECK = 4
#   def __init__(
#       self,
#       app_screen_checker: AppScreenChecker,
#       check_frequency: int,
#       max_failed_current_activity: int,
#       block_input: bool,
#       block_output: bool,
#       name: str = 'dumpsys',
#   ):
#   def main(self):


# Path: android_env/components/dumpsys_thread_test.py
from absl.testing import absltest
from android_env.components import app_screen_checker as screen_checker
from android_env.components import dumpsys_thread
import mock

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for android_env.components.dumpsys_thread."""




class DumpsysThreadTest(absltest.TestCase):

  def setUp(self):
    super().setUp()
    self._dumpsys_thread = dumpsys_thread.DumpsysThread(
        app_screen_checker=mock.create_autospec(
            screen_checker.AppScreenChecker),
        check_frequency=1,
        max_failed_current_activity=5,
        block_input=True,
        block_output=True)

  def test_unexpected_activity(self):

    outcome = screen_checker.AppScreenChecker.Outcome.UNEXPECTED_ACTIVITY