/*
 * Copyright 2015 Johan Walles <johan.walles@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.gmail.walles.johan.exactype;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ExactypeModeTest {
    private static final String[] BASE = new String[] { "Base" };
    private static final String[] CAPS = new String[] { "Caps" };
    private static final String[] NUMERIC = new String[] { "Numeric" };
    private static final String[] NUMLOCK = new String[] { "Numlocked" };

    private abstract static class Generator {
        private final ExactypeMode mode;

        public Generator() {
            mode = setUp(new ExactypeMode(BASE, CAPS, NUMERIC, NUMLOCK));
        }

        public ExactypeMode getMode() {
            return mode;
        }

        public abstract ExactypeMode setUp(ExactypeMode mode);
    };

    fixme: Make @Before and @After methods to ensure we checked assertModeTransition() on all event types

    @Test
    public void testInitial() {
        Generator generator = new Generator() {
            @Override
            public ExactypeMode setUp(ExactypeMode mode) {
                return mode;
            }
        };

        assertModeTransition(generator, ExactypeMode.Event.INSERT_CHAR, BASE);
        assertModeTransition(generator, ExactypeMode.Event.SHIFT, CAPS);
        assertModeTransition(generator, ExactypeMode.Event.LONG_PRESS, NUMERIC);
        assertModeTransition(generator, ExactypeMode.Event.NUM_LOCK, NUMLOCK);
        assertModeTransition(generator, ExactypeMode.Event.ALPHABETIC, CAPS);
    }
}

@@ -681,16 +681,41 @@
 .After;%0A
+import org.junit.Assert;%0A
 import o
@@ -755,16 +755,95 @@
 .Test;%0A%0A
+import java.util.Collections;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 public c
@@ -1141,24 +1141,75 @@
 locked%22 %7D;%0A%0A
+    private Set%3CExactypeMode.Event%3E needsTesting;%0A%0A
     private 
@@ -1546,116 +1546,678 @@
    %7D
-;
 %0A%0A    
-fixme: Make @Before and @After methods to ensure we checked assertModeTransition() on all event types
+@Before%0A    public void setUp() %7B%0A        needsTesting = new HashSet%3C%3E();%0A%0A        Collections.addAll(needsTesting, ExactypeMode.Event.values());%0A    %7D%0A%0A    @After%0A    public void postVerification() %7B%0A        Assert.assertEquals(%22These weren't tested: %22 + needsTesting.toString(),%0A            0, needsTesting.size());%0A    %7D%0A%0A    private void assertModeTransition(%0A        Generator generator, ExactypeMode.Event event, String%5B%5D expected_outcome)%0A    %7B%0A        Assert.assertTrue(needsTesting.remove(event));%0A%0A        ExactypeMode mode = generator.getMode();%0A        mode.register(event);%0A        Assert.assertArrayEquals(expected_outcome, mode.getKeyboard());%0A    %7D
 %0A%0A  

Refactor keyboard mode unit tests