1 /*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17
18 #include <gtest/gtest.h>
19 #include <task/ModelBuilder.h>
20
21
22 class ModelBuilderTest : public testing::Test {
23 public:
24 ModelBuilder mModelBuilder;
25 };
26
TEST_F(ModelBuilderTest,ParsingCaseNoAttribTest)27 TEST_F(ModelBuilderTest, ParsingCaseNoAttribTest) {
28 android::String8 xmlFile("test_description/test/no_attrib.xml");
29 TaskGeneric* testCase = mModelBuilder.parseTestDescriptionXml(xmlFile);
30 ASSERT_TRUE(testCase != NULL);
31 //TODO verify TestCase
32 delete testCase;
33 }
34
TEST_F(ModelBuilderTest,ParsingCaseTest)35 TEST_F(ModelBuilderTest, ParsingCaseTest) {
36 android::String8 xmlFile("test_description/host_speaker_calibration.xml");
37 TaskGeneric* testCase = mModelBuilder.parseTestDescriptionXml(xmlFile);
38 ASSERT_TRUE(testCase != NULL);
39 //TODO verify TestCase
40 delete testCase;
41 }
42
TEST_F(ModelBuilderTest,ParsingBatchTest)43 TEST_F(ModelBuilderTest, ParsingBatchTest) {
44 android::String8 xmlFile("test_description/all_playback.xml");
45 TaskGeneric* testBatch = mModelBuilder.parseTestDescriptionXml(xmlFile);
46 ASSERT_TRUE(testBatch != NULL);
47 //TODO verify TestCase
48 delete testBatch;
49 }
50
TEST_F(ModelBuilderTest,CaseOnlyTest)51 TEST_F(ModelBuilderTest, CaseOnlyTest) {
52 android::String8 xmlFile("test_description/all_playback.xml");
53 TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile, true);
54 ASSERT_TRUE(task == NULL);
55
56 delete task;
57 }
58
TEST_F(ModelBuilderTest,MissingMandatoryTest)59 TEST_F(ModelBuilderTest, MissingMandatoryTest) {
60 android::String8 xmlFile("test_description/test/missing_mandatory.xml");
61 TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
62 ASSERT_TRUE(task == NULL);
63 delete task;
64 }
65
TEST_F(ModelBuilderTest,UnknownElementTest)66 TEST_F(ModelBuilderTest, UnknownElementTest) {
67 android::String8 xmlFile("test_description/test/unknown_element.xml");
68 TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
69 ASSERT_TRUE(task == NULL);
70 delete task;
71 }
72
TEST_F(ModelBuilderTest,WrongAttributeTest)73 TEST_F(ModelBuilderTest, WrongAttributeTest) {
74 android::String8 xmlFile("test_description/test/wrong_attrib.xml");
75 TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
76 ASSERT_TRUE(task == NULL);
77 delete task;
78 }
79
TEST_F(ModelBuilderTest,BuiltinRMSTest)80 TEST_F(ModelBuilderTest, BuiltinRMSTest) {
81 android::String8 xmlFile("test_description/test/test_rms_vma.xml");
82 TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
83 ASSERT_TRUE(task != NULL);
84 TaskGeneric::ExecutionResult result = task->run();
85 ASSERT_TRUE((result == TaskGeneric::EResultOK) || (result == TaskGeneric::EResultPass));
86 delete task;
87 }
88
89