• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 
19 #include "user_input_test.h"
20 
21 #define DTMF_TEST_INPUT '1'
22 #define DTMF_TEST_UPDATE false
23 #define DTMF_TEST_DURATION 20
24 
25 #define ALPHANUMERIC_STRING_LENGTH 16
26 uint8 alphanumericTestString[ALPHANUMERIC_STRING_LENGTH] =
27 {
28     '0', '1', '2', '3', '4', '5', '6', '7',
29     '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
30 };
31 
test()32 void user_input_test::test()
33 {
34     fprintf(fileoutput, "Start user input test, is dtmf %d, proxy %d.\n", iIsDTMF, iUseProxy);
35     int error = 0;
36 
37     scheduler = OsclExecScheduler::Current();
38 
39     this->AddToScheduler();
40 
41     if (start_async_test())
42     {
43         OSCL_TRY(error, scheduler->StartScheduler());
44         if (error != 0)
45         {
46             OSCL_LEAVE(error);
47         }
48     }
49 
50     destroy_sink_source();
51 
52     this->RemoveFromScheduler();
53 }
54 
55 
Run()56 void user_input_test::Run()
57 {
58     if (terminal)
59     {
60         if (iUseProxy)
61         {
62             //CPV2WayProxyFactory::DeleteTerminal(terminal);
63         }
64         else
65         {
66             CPV2WayEngineFactory::DeleteTerminal(terminal);
67         }
68         terminal = NULL;
69     }
70 
71     scheduler->StopScheduler();
72 }
73 
DoCancel()74 void user_input_test::DoCancel()
75 {
76 }
77 
H324MConfigCommandCompletedL(PVMFCmdResp & aResponse)78 void user_input_test::H324MConfigCommandCompletedL(PVMFCmdResp& aResponse)
79 {
80     OSCL_UNUSED_ARG(aResponse);
81 }
82 
H324MConfigHandleInformationalEventL(PVMFAsyncEvent & aEvent)83 void user_input_test::H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aEvent)
84 {
85     switch (aEvent.GetEventType())
86     {
87         case PV_INDICATION_USER_INPUT:
88             break;
89         case PV_INDICATION_USER_INPUT_CAPABILITY:
90             break;
91     }
92 }
93 
HandleInformationalEvent(const PVAsyncInformationalEvent & aEvent)94 void user_input_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
95 {
96     OSCL_UNUSED_ARG(aEvent);
97 }
98 
RstCmdCompleted()99 void user_input_test::RstCmdCompleted()
100 {
101     RunIfNotReady();
102 }
103 
DisCmdSucceeded()104 void user_input_test::DisCmdSucceeded()
105 {
106     printf("Finished disconnecting \n");
107     if (i324mConfigInterface)
108         i324mConfigInterface->removeRef();
109     reset();
110 }
111 
DisCmdFailed()112 void user_input_test::DisCmdFailed()
113 {
114     printf("Finished disconnecting \n");
115     if (i324mConfigInterface)
116         i324mConfigInterface->removeRef();
117     reset();
118 }
119 
ConnectSucceeeded()120 void user_input_test::ConnectSucceeeded()
121 {
122     i324mConfigInterface = iH324MConfig;
123 //      OSCL_TRY(error, i324mIFCommandId = terminal->QueryInterface(PVH324MConfigUuid, i324mConfigInterface,NULL));
124     if (i324mConfigInterface == NULL)
125     {
126         test_is_true(false);
127         disconnect();
128     }
129     H324MConfigInterface * i324Interface = (H324MConfigInterface *)i324mConfigInterface;
130     i324Interface->SetObserver(this);
131     iUserInputId = i324Interface->SendUserInput(iUserInput);
132 }
133 
InitFailed()134 void user_input_test::InitFailed()
135 {
136     test_is_true(false);
137     RunIfNotReady();
138 }
139 
start_async_test()140 bool user_input_test::start_async_test()
141 {
142     if (iIsDTMF)
143     {
144         iUserInput = new CPVUserInputDtmf(DTMF_TEST_INPUT, DTMF_TEST_UPDATE, DTMF_TEST_DURATION);
145     }
146     else
147     {
148         iUserInput = new CPVUserInputAlphanumeric(alphanumericTestString, ALPHANUMERIC_STRING_LENGTH);
149     }
150 
151     if (iUserInput == NULL)
152     {
153         test_is_true(false);
154         return false;
155     }
156 
157 
158     return test_base::start_async_test();;
159 }
160 
161 
162 
163 
164 
165