!223 需求新增innerkits接口测试用例覆盖

Merge pull request !223 from 赵凌岚/master
This commit is contained in:
openharmony_ci 2022-08-19 11:17:35 +00:00 committed by Gitee
commit d38ea9eed4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 105 additions and 20 deletions

View File

@ -12,18 +12,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <functional>
#include <gtest/gtest.h>
#include <cstdint>
#include <vector>
#include <sys/time.h>
#include <thread>
#include <cstdint>
#include <functional>
#include <string>
#include <thread>
#include <vector>
#include "global.h"
#include "input_method_agent_stub.h"
#include "input_method_core_stub.h"
#include "input_control_channel_stub.h"
#include "i_input_data_channel.h"
#include "input_attribute.h"
#include "input_control_channel_stub.h"
#include "input_data_channel_proxy.h"
#include "input_data_channel_stub.h"
#include "input_method_agent_stub.h"
#include "input_method_core_proxy.h"
#include "input_method_core_stub.h"
#include "message_handler.h"
using namespace testing::ext;
@ -89,6 +96,41 @@ namespace MiscServices {
EXPECT_TRUE(iface != nullptr);
}
/**
* @tc.name: testShowKeyboardInputMethodCoreProxy
* @tc.desc: Test InputMethodCoreProxy ShowKeyboard
* @tc.type: FUNC
*/
HWTEST_F(InputMethodAbilityTest, testShowKeyboardInputMethodCoreProxy, TestSize.Level0)
{
sptr<InputMethodCoreStub> coreStub = new InputMethodCoreStub(0);
sptr<IInputMethodCore> core = coreStub;
sptr<InputDataChannelStub> channelStub = new InputDataChannelStub();
MessageParcel data;
data.WriteRemoteObject(core->AsObject());
data.WriteRemoteObject(channelStub->AsObject());
sptr<IRemoteObject> coreObject = data.ReadRemoteObject();
sptr<IRemoteObject> channelObject = data.ReadRemoteObject();
sptr<InputMethodCoreProxy> coreProxy = new InputMethodCoreProxy(coreObject);
sptr<InputDataChannelProxy> channelProxy = new InputDataChannelProxy(channelObject);
auto ret = coreProxy->showKeyboard(channelProxy, true);
EXPECT_TRUE(ret);
}
/**
* @tc.name: testShowKeyboardInputMethodCoreStub
* @tc.desc: Test InputMethodCoreStub ShowKeyboard
* @tc.type: FUNC
*/
HWTEST_F(InputMethodAbilityTest, testShowKeyboardInputMethodCoreStub, TestSize.Level0)
{
sptr<InputMethodCoreStub> coreStub = new InputMethodCoreStub(0);
auto ret = coreStub->showKeyboard(nullptr, true);
EXPECT_TRUE(!ret);
}
/**
* @tc.name: testReadWriteIInputControlChannel
* @tc.desc: Checkout IInputControlChannel.

View File

@ -12,24 +12,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <functional>
#include <gtest/gtest.h>
#include <cstdint>
#include <vector>
#include <sys/time.h>
#include <thread>
#include <string>
#include "global.h"
#include "utils.h"
#include "input_method_controller.h"
#include "i_input_method_system_ability.h"
#include <gtest/gtest.h>
#include <sys/time.h>
#include <cstdint>
#include <functional>
#include <string>
#include <thread>
#include <vector>
#include "global.h"
#include "i_input_method_agent.h"
#include "input_data_channel_stub.h"
#include "i_input_method_system_ability.h"
#include "input_client_stub.h"
#include "input_data_channel_stub.h"
#include "input_method_setting.h"
#include "input_method_system_ability_proxy.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "input_method_setting.h"
#include "utils.h"
#include "message_parcel.h"
using namespace testing::ext;
namespace OHOS {
@ -226,6 +230,10 @@ namespace MiscServices {
imc->Attach(textListener, false);
sleep(waitForStatusOk);
IMSA_HILOGI("IMC ShowCurrentInput START");
imc->ShowCurrentInput();
sleep(waitForStatusOk);
IMSA_HILOGI("IMC ShowTextInput START");
imc->ShowTextInput();
sleep(10);
@ -239,5 +247,40 @@ namespace MiscServices {
sleep(waitForStatusOk);
IMSA_HILOGI("IMC TEST OVER");
}
/**
* @tc.name: testIMCShowCurrentInput
* @tc.desc: IMC ShowCurrentInput.
* @tc.type: FUNC
*/
HWTEST_F(InputMethodControllerTest, testIMCShowCurrentInput, TestSize.Level0)
{
IMSA_HILOGI("IMC ShowCurrentInput Test START");
sptr<InputMethodController> imc = InputMethodController::GetInstance();
EXPECT_TRUE(imc != nullptr);
int32_t ret = imc->ShowCurrentInput();
EXPECT_TRUE(ret == 0);
}
/**
* @tc.name: testIMSAProxyShowCurrentInput
* @tc.desc: IMSAProxy ShowCurrentInput.
* @tc.type: FUNC
*/
HWTEST_F(InputMethodControllerTest, testIMSAProxyShowCurrentInput, TestSize.Level0)
{
IMSA_HILOGI("IMSAProxy ShowCurrentInput Test START");
sptr<ISystemAbilityManager> systemAbilityManager =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, "");
sptr<InputMethodSystemAbilityProxy> imsaProxy = new InputMethodSystemAbilityProxy(systemAbility);
MessageParcel data;
data.WriteInterfaceToken(imsaProxy->GetDescriptor());
int32_t ret = imsaProxy->ShowCurrentInput(data);
EXPECT_TRUE(ret == 0);
}
} // namespace MiscServices
} // namespace OHOS