/*
 * 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.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import static org.junit.Assert.*;

public class KeyCoordinatorTest {
    @Test
    public void testSingleChar() throws Exception {
        KeyCoordinator testMe = new KeyCoordinator(new String[] {"A"}, 200, 100);
        List<KeyCoordinator.KeyInfo> coordinates = new ArrayList<>();
        for (KeyCoordinator.KeyInfo keyInfo : testMe) {
            coordinates.add(keyInfo);
        }

        KeyCoordinator.KeyInfo[] expectedCoordinates = new KeyCoordinator.KeyInfo[] {
            new KeyCoordinator.KeyInfo(100, 50, 'A')
        };

        Assert.assertArrayEquals(expectedCoordinates, coordinates.toArray());
    }

    @Test
    public void test2x2() throws Exception {
        Assert.fail("This test has not been written yet");
    }
}

@@ -894,63 +894,131 @@
     
-@Test%0A    public void testSingleChar() throws Exception
+private void testIteration(%0A        String%5B%5D rows, int width, int height, KeyCoordinator.KeyInfo%5B%5D expectedCoordinates)%0A   
  %7B%0A 
@@ -1071,36 +1071,27 @@
 tor(
-new String%5B%5D %7B%22A%22%7D, 200, 100
+rows, width, height
 );%0A 
@@ -1276,54 +1276,216 @@
     
-KeyCoordinator.KeyInfo%5B%5D expectedCoordinates =
+Assert.assertArrayEquals(expectedCoordinates, coordinates.toArray());%0A    %7D%0A%0A    @Test%0A    public void testPlacement() %7B%0A        // Test single key keyboard%0A        testIteration(new String%5B%5D %7B%22A%22%7D, 200, 100,
  new
@@ -1574,16 +1574,17 @@
        %7D
+)
 ;%0A%0A     
@@ -1590,196 +1590,346 @@
     
-Assert.assertArrayEquals(expectedCoordinates, coordinates.toArray());
+// Test 2x2 keyboard%0A        testIteration(new String%5B%5D %7B%22AB%22, %22CD%22%7D, 300, 150, new KeyCoordinator.KeyInfo%5B%5D %7B%0A            new KeyCoordinator.KeyInfo(100, 50, 'A'),
 %0A    
-%7D%0A%0A
     
-@Test%0A    public void test2x2() throws Exception %7B%0A        Assert.fail(%22This test has not been written yet%22
+    new KeyCoordinator.KeyInfo(200, 50, 'B'),%0A            new KeyCoordinator.KeyInfo(100, 100, 'C'),%0A            new KeyCoordinator.KeyInfo(200, 100, 'D'),%0A        %7D
 );%0A 

Add another key placement test case