2021-04-18 08:20:21 +02:00
|
|
|
// Copyright 2021, Shy.
|
|
|
|
//
|
|
|
|
// This file is part of Kitchentimer.
|
|
|
|
//
|
|
|
|
// Kitchentimer is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Kitchentimer is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Kitchentimer. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
use crate::clock::{Clock, font};
|
2021-04-17 18:20:39 +02:00
|
|
|
use crate::layout::Layout;
|
2021-04-20 21:53:25 +02:00
|
|
|
use crate::{Config, Cradle};
|
2021-04-09 07:48:27 +02:00
|
|
|
|
|
|
|
fn default_config() -> Config {
|
|
|
|
Config {
|
2021-04-18 08:20:21 +02:00
|
|
|
fancy: false,
|
2021-04-09 07:48:27 +02:00
|
|
|
quit: false,
|
2021-04-20 21:53:25 +02:00
|
|
|
commands: Cradle::new(),
|
2021-04-18 08:20:21 +02:00
|
|
|
font: &font::NORMAL,
|
2021-04-09 07:48:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test if layout computation works without panicking.
|
|
|
|
#[test]
|
|
|
|
fn layout_computation() {
|
|
|
|
let config = default_config();
|
2021-04-12 10:21:30 +02:00
|
|
|
let mut clock = Clock::new(&config);
|
2021-04-18 08:20:21 +02:00
|
|
|
let mut layout = Layout::new();
|
2021-04-09 07:48:27 +02:00
|
|
|
|
2021-04-12 10:21:30 +02:00
|
|
|
// Two segment display.
|
2021-04-09 07:48:27 +02:00
|
|
|
for roster_width in &[0, 10, 20, 30, 40] {
|
|
|
|
for width in 0..256 {
|
|
|
|
for height in 0..128 {
|
2021-04-12 10:21:30 +02:00
|
|
|
layout.test_update(&clock, width, height, *roster_width);
|
2021-04-09 07:48:27 +02:00
|
|
|
}
|
2021-04-12 10:21:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Three segment display.
|
|
|
|
clock.elapsed = 3600;
|
|
|
|
for roster_width in &[0, 10, 20, 30, 40] {
|
|
|
|
for width in 0..256 {
|
|
|
|
for height in 0..128 {
|
|
|
|
layout.test_update(&clock, width, height, *roster_width);
|
|
|
|
}
|
|
|
|
}
|
2021-04-09 07:48:27 +02:00
|
|
|
}
|
|
|
|
}
|