Skip to content

Commit

Permalink
window_id build for each test step
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jan 19, 2024
1 parent 9b0f3bb commit 3a39da3
Showing 1 changed file with 57 additions and 15 deletions.
72 changes: 57 additions & 15 deletions frontends/rioterm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,28 +670,34 @@ pub mod test {
use super::*;
use crate::event::VoidListener;

#[cfg(target_os = "macos")]
const WINDOW_ID: WindowId = 0;

#[cfg(not(target_os = "macos"))]
const WINDOW_ID: WindowId = WindowId::from(0);

#[test]
fn test_capacity() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let context_manager =
ContextManager::start_with_capacity(5, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(5, VoidListener {}, window_id).unwrap();
assert_eq!(context_manager.capacity, 5);

let mut context_manager =
ContextManager::start_with_capacity(5, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(5, VoidListener {}, window_id).unwrap();
context_manager.increase_capacity(3);
assert_eq!(context_manager.capacity, 8);
}

#[test]
fn test_add_context() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(5, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(5, VoidListener {}, window_id).unwrap();
assert_eq!(context_manager.capacity, 5);
assert_eq!(context_manager.current_index, 0);

Expand All @@ -716,8 +722,14 @@ pub mod test {

#[test]
fn test_add_context_start_with_capacity_limit() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(3, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(3, VoidListener {}, window_id).unwrap();
assert_eq!(context_manager.capacity, 3);
assert_eq!(context_manager.current_index, 0);
let should_redirect = false;
Expand Down Expand Up @@ -748,8 +760,14 @@ pub mod test {

#[test]
fn test_set_current() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(8, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(8, VoidListener {}, window_id).unwrap();
let should_redirect = true;

context_manager.add_context(
Expand Down Expand Up @@ -783,8 +801,14 @@ pub mod test {

#[test]
fn test_close_context() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(3, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(3, VoidListener {}, window_id).unwrap();
let should_redirect = false;

context_manager.add_context(
Expand Down Expand Up @@ -812,8 +836,14 @@ pub mod test {

#[test]
fn test_close_context_upcoming_ids() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(5, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(5, VoidListener {}, window_id).unwrap();
let should_redirect = false;

context_manager.add_context(
Expand Down Expand Up @@ -861,8 +891,14 @@ pub mod test {

#[test]
fn test_close_last_context() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(2, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(2, VoidListener {}, window_id).unwrap();
let should_redirect = false;

context_manager.add_context(
Expand All @@ -888,8 +924,14 @@ pub mod test {

#[test]
fn test_switch_to_next() {
#[cfg(target_os = "macos")]
let window_id: WindowId = 0;

#[cfg(not(target_os = "macos"))]
let window_id: WindowId = WindowId::from(0);

let mut context_manager =
ContextManager::start_with_capacity(5, VoidListener {}, WINDOW_ID).unwrap();
ContextManager::start_with_capacity(5, VoidListener {}, window_id).unwrap();
let should_redirect = false;

context_manager.add_context(
Expand Down

0 comments on commit 3a39da3

Please sign in to comment.