diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2014-05-02 20:01:46 +0200 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2014-05-02 20:01:46 +0200 |
commit | 9660a7a64c749e181d2114cc4b66a8aa4f88be0f (patch) | |
tree | 1664b0ed1ee20f66cf3b7f550c33d49c897bed8c /tests/Properties/Layout | |
parent | b682eaf8fcbb548dacb35b4103e546cbd9fca3ed (diff) | |
download | xmonad-9660a7a64c749e181d2114cc4b66a8aa4f88be0f.tar.gz xmonad-9660a7a64c749e181d2114cc4b66a8aa4f88be0f.tar.xz xmonad-9660a7a64c749e181d2114cc4b66a8aa4f88be0f.zip |
update testsuite (mostly due Jesper Reenberg)
Ignore-this: a5e926aa4e397e70d56e3c9db7108d5b
* use quickcheck2
* run them using cabal's test-suite field
* split up Properties into separate files
darcs-hash:20140502180146-1499c-dc8c09c3ec76a42a0e146925adce960435dc81db.gz
Diffstat (limited to 'tests/Properties/Layout')
-rw-r--r-- | tests/Properties/Layout/Full.hs | 34 | ||||
-rw-r--r-- | tests/Properties/Layout/Tall.hs | 116 |
2 files changed, 150 insertions, 0 deletions
diff --git a/tests/Properties/Layout/Full.hs b/tests/Properties/Layout/Full.hs new file mode 100644 index 0000000..eca6ec3 --- /dev/null +++ b/tests/Properties/Layout/Full.hs @@ -0,0 +1,34 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module Properties.Layout.Full where + +import Test.QuickCheck +import Instances + +import XMonad.StackSet hiding (filter) +import XMonad.Core +import XMonad.Layout + +import Data.Maybe + +------------------------------------------------------------------------ +-- Full layout + +-- pureLayout works for Full +prop_purelayout_full rect = do + x <- (arbitrary :: Gen T) `suchThat` (isJust . peek) + let layout = Full + st = fromJust . stack . workspace . current $ x + ts = pureLayout layout rect st + return $ + length ts == 1 -- only one window to view + && + snd (head ts) == rect -- and sets fullscreen + && + fst (head ts) == fromJust (peek x) -- and the focused window is shown + + +-- what happens when we send an IncMaster message to Full --- Nothing +prop_sendmsg_full (NonNegative k) = + isNothing (Full `pureMessage` (SomeMessage (IncMasterN k))) + +prop_desc_full = description Full == show Full diff --git a/tests/Properties/Layout/Tall.hs b/tests/Properties/Layout/Tall.hs new file mode 100644 index 0000000..7464184 --- /dev/null +++ b/tests/Properties/Layout/Tall.hs @@ -0,0 +1,116 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module Properties.Layout.Tall where + +import Test.QuickCheck +import Instances +import Utils + +import XMonad.StackSet hiding (filter) +import XMonad.Core +import XMonad.Layout + +import Graphics.X11.Xlib.Types (Rectangle(..)) + +import Data.Maybe +import Data.List (sort) +import Data.Ratio + +------------------------------------------------------------------------ +-- The Tall layout + +-- 1 window should always be tiled fullscreen +prop_tile_fullscreen rect = tile pct rect 1 1 == [rect] + where pct = 1/2 + +-- multiple windows +prop_tile_non_overlap rect windows nmaster = noOverlaps (tile pct rect nmaster windows) + where _ = rect :: Rectangle + pct = 3 % 100 + +-- splitting horizontally yields sensible results +prop_split_hoziontal (NonNegative n) x = + sum (map rect_width xs) == rect_width x + && + all (== rect_height x) (map rect_height xs) + && + (map rect_x xs) == (sort $ map rect_x xs) + + where + xs = splitHorizontally n x + +-- splitting horizontally yields sensible results +prop_splitVertically (r :: Rational) x = + + rect_x x == rect_x a && rect_x x == rect_x b + && + rect_width x == rect_width a && rect_width x == rect_width b + where + (a,b) = splitVerticallyBy r x + + +-- pureLayout works. +prop_purelayout_tall n r1 r2 rect = do + x <- (arbitrary :: Gen T) `suchThat` (isJust . peek) + let layout = Tall n r1 r2 + st = fromJust . stack . workspace . current $ x + ts = pureLayout layout rect st + return $ + length ts == length (index x) + && + noOverlaps (map snd ts) + && + description layout == "Tall" + + +-- Test message handling of Tall + +-- what happens when we send a Shrink message to Tall +prop_shrink_tall (NonNegative n) (NonZero (NonNegative delta)) (NonNegative frac) = + n == n' && delta == delta' -- these state components are unchanged + && frac' <= frac && (if frac' < frac then frac' == 0 || frac' == frac - delta + else frac == 0 ) + -- remaining fraction should shrink + where + l1 = Tall n delta frac + Just l2@(Tall n' delta' frac') = l1 `pureMessage` (SomeMessage Shrink) + -- pureMessage :: layout a -> SomeMessage -> Maybe (layout a) + + +-- what happens when we send a Shrink message to Tall +prop_expand_tall (NonNegative n) + (NonZero (NonNegative delta)) + (NonNegative n1) + (NonZero (NonNegative d1)) = + + n == n' + && delta == delta' -- these state components are unchanged + && frac' >= frac + && (if frac' > frac + then frac' == 1 || frac' == frac + delta + else frac == 1 ) + + -- remaining fraction should shrink + where + frac = min 1 (n1 % d1) + l1 = Tall n delta frac + Just l2@(Tall n' delta' frac') = l1 `pureMessage` (SomeMessage Expand) + -- pureMessage :: layout a -> SomeMessage -> Maybe (layout a) + +-- what happens when we send an IncMaster message to Tall +prop_incmaster_tall (NonNegative n) (NonZero (NonNegative delta)) (NonNegative frac) + (NonNegative k) = + delta == delta' && frac == frac' && n' == n + k + where + l1 = Tall n delta frac + Just l2@(Tall n' delta' frac') = l1 `pureMessage` (SomeMessage (IncMasterN k)) + -- pureMessage :: layout a -> SomeMessage -> Maybe (layout a) + + + + -- toMessage LT = SomeMessage Shrink + -- toMessage EQ = SomeMessage Expand + -- toMessage GT = SomeMessage (IncMasterN 1) + + +prop_desc_mirror n r1 r2 = description (Mirror $! t) == "Mirror Tall" + where t = Tall n r1 r2 |