Skip to content

Commit

Permalink
Fix test_blinking_animation_deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
plbrault committed Jul 22, 2024
1 parent f8bd8bb commit 7552517
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/game_objects/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ def _handle_events(self, events):
if self._check_if_clicked_on(event):
self._on_click()

def _handle_pages_on_disk(self):
pages_on_disk = 0
def _handle_unavailable_pages(self):
unavailable_pages = 0
if self.has_cpu:
for page in self._pages:
if page.on_disk:
pages_on_disk += 1
self._set_waiting_for_page(pages_on_disk > 0)
if page.on_disk or page.swap_requested:
unavailable_pages += 1
self._set_waiting_for_page(unavailable_pages > 0)

def _update_starvation_level(self, current_time):
if self.has_cpu and not self.is_blocked:
Expand Down Expand Up @@ -319,7 +319,7 @@ def update(self, current_time, events):
self._handle_events(events)

if not self.has_ended:
self._handle_pages_on_disk()
self._handle_unavailable_pages()
if current_time >= self._last_event_check_time + ONE_SECOND:
self._last_event_check_time = current_time
self._update_starvation_level(current_time)
Expand Down
2 changes: 2 additions & 0 deletions src/tests/game_objects/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,11 @@ def test_blinking_animation_deactivation(self, stage):

process.use_cpu()
stage.page_manager.get_page(1, 0).request_swap()
stage.page_manager.update(1000, [])
process.update(1000, [])

stage.page_manager.get_page(1, 0).request_swap()
stage.page_manager.update(2000, [])
process.update(2000, [])

for i in range(1, 5):
Expand Down

0 comments on commit 7552517

Please sign in to comment.