summaryrefslogtreecommitdiffstats
path: root/src/tests/fakes
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2019-10-09 21:53:23 +0200
committerAram Drevekenin <aram@poor.dev>2019-10-09 21:53:23 +0200
commit3e1b6d18bcc0a678c1da1be4a8bf53c19fbb98bd (patch)
treed02586aa62c16e7d5c69368777463a219dea71d6 /src/tests/fakes
parent55c830d6bb15af66534ba81fdb9a130b63144d4a (diff)
test(ui): new details and responsive layout
Diffstat (limited to 'src/tests/fakes')
-rw-r--r--src/tests/fakes/fake_input.rs10
-rw-r--r--src/tests/fakes/fake_output.rs23
2 files changed, 21 insertions, 12 deletions
diff --git a/src/tests/fakes/fake_input.rs b/src/tests/fakes/fake_input.rs
index ea1f34c..b45587b 100644
--- a/src/tests/fakes/fake_input.rs
+++ b/src/tests/fakes/fake_input.rs
@@ -89,8 +89,8 @@ pub fn get_open_sockets() -> HashMap<Connection, String> {
let mut open_sockets = HashMap::new();
open_sockets.insert(
Connection::new(
- SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)), 443),
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 12345),
+ 443,
Protocol::Tcp,
)
.unwrap(),
@@ -98,8 +98,8 @@ pub fn get_open_sockets() -> HashMap<Connection, String> {
);
open_sockets.insert(
Connection::new(
- SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)), 443),
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(2, 2, 2, 2)), 54321),
+ 443,
Protocol::Tcp,
)
.unwrap(),
@@ -107,8 +107,8 @@ pub fn get_open_sockets() -> HashMap<Connection, String> {
);
open_sockets.insert(
Connection::new(
- SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)), 443),
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(3, 3, 3, 3)), 1337),
+ 443,
Protocol::Tcp,
)
.unwrap(),
@@ -116,8 +116,8 @@ pub fn get_open_sockets() -> HashMap<Connection, String> {
);
open_sockets.insert(
Connection::new(
- SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)), 443),
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(4, 4, 4, 4)), 1337),
+ 443,
Protocol::Tcp,
)
.unwrap(),
@@ -125,8 +125,8 @@ pub fn get_open_sockets() -> HashMap<Connection, String> {
);
open_sockets.insert(
Connection::new(
- SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)), 443),
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 12346),
+ 443,
Protocol::Tcp,
)
.unwrap(),
diff --git a/src/tests/fakes/fake_output.rs b/src/tests/fakes/fake_output.rs
index 6fb356c..2112371 100644
--- a/src/tests/fakes/fake_output.rs
+++ b/src/tests/fakes/fake_output.rs
@@ -18,20 +18,24 @@ pub enum TerminalEvent {
pub struct TestBackend {
pub events: Arc<Mutex<Vec<TerminalEvent>>>,
pub draw_events: Arc<Mutex<Vec<String>>>,
- terminal_width: u16,
- terminal_height: u16,
+ terminal_width: Arc<Mutex<u16>>,
+ terminal_height: Arc<Mutex<u16>>,
}
impl TestBackend {
pub fn new(
log: Arc<Mutex<Vec<TerminalEvent>>>,
draw_log: Arc<Mutex<Vec<String>>>,
+ terminal_width: Arc<Mutex<u16>>, // 190
+ terminal_height: Arc<Mutex<u16>>, // 50
) -> TestBackend {
TestBackend {
events: log,
draw_events: draw_log,
- terminal_width: 190,
- terminal_height: 50,
+ terminal_width,
+ terminal_height,
+// terminal_width: 190,
+// terminal_height: 50,
}
}
}
@@ -78,8 +82,10 @@ impl Backend for TestBackend {
for (x, y, cell) in content {
coordinates.insert(Point { x, y }, cell);
}
- for y in 0..self.terminal_height {
- for x in 0..self.terminal_width {
+ let terminal_height = self.terminal_height.lock().unwrap();
+ let terminal_width = self.terminal_width.lock().unwrap();
+ for y in 0..*terminal_height {
+ for x in 0..*terminal_width {
match coordinates.get(&Point { x, y }) {
Some(cell) => {
// this will contain no style information at all
@@ -98,7 +104,10 @@ impl Backend for TestBackend {
}
fn size(&self) -> io::Result<Rect> {
- Ok(Rect::new(0, 0, self.terminal_width, self.terminal_height))
+ let terminal_height = self.terminal_height.lock().unwrap();
+ let terminal_width = self.terminal_width.lock().unwrap();
+
+ Ok(Rect::new(0, 0, *terminal_width, *terminal_height))
}
fn flush(&mut self) -> io::Result<()> {