• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.inputmethod.keyboard.internal;
18 
19 import com.android.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException;
20 
21 import android.test.AndroidTestCase;
22 import android.test.suitebuilder.annotation.SmallTest;
23 
24 @SmallTest
25 public class SmoothingUtilsTests extends AndroidTestCase {
26     // "run tests" -c com.android.inputmethod.keyboard.internal.SmoothingUtilsTests
27     private static final boolean DEBUG = false;
28 
testGet3DParamaters()29     public void testGet3DParamaters() {
30         final float[] xs = new float[] {0, 1, 2, 3, 4};
31         final float[] ys = new float[] {1, 4, 15, 40, 85}; // y = x^3 + x^2 + x + 1
32         final float[][] retval = new float[4][1];
33         try {
34             SmoothingUtils.get3DParameters(xs, ys, retval);
35             if (DEBUG) {
36                 MatrixUtils.dump("3d", retval);
37             }
38             for (int i = 0; i < 4; ++i) {
39                 MatrixUtilsTests.assertEqualsFloat(retval[i][0], 1.0f, 0.001f);
40             }
41         } catch (MatrixOperationFailedException e) {
42             assertTrue(false);
43         }
44     }
45 }
46