-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6735903
commit d640d4a
Showing
22 changed files
with
666 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
autostart = "@PLUGIN_TESTAUTOMATIONCOMRPC_AUTOSTART@" | ||
|
||
configuration = JSON() | ||
|
||
rootobject = JSON() | ||
rootobject.add("mode", "Local") | ||
configuration.add("root", rootobject) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2020 Metrological | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "TestAutomationComRpc.h" | ||
|
||
|
||
namespace WPEFramework { | ||
namespace Plugin { | ||
|
||
namespace { | ||
|
||
static Metadata<TestAutomationComRpc> metadata( | ||
// Version | ||
1, 0, 0, | ||
// Preconditions | ||
{}, | ||
// Terminations | ||
{}, | ||
// Controls | ||
{} | ||
); | ||
} | ||
|
||
const string TestAutomationComRpc::Initialize(PluginHost::IShell* service) | ||
{ | ||
ASSERT (_service == nullptr); | ||
ASSERT (service != nullptr); | ||
|
||
_service = service; | ||
_service->AddRef(); | ||
|
||
_implementation = _service->Root<Exchange::TestAutomation::IComRpc::IComRpcInternal>(_connectionId, 2000, _T("TestAutomationComRpcImplementation")); | ||
Exchange::TestAutomation::JComRpc::Register(*this, this); | ||
|
||
string result; | ||
if (_implementation == nullptr) { | ||
result = _T("Couldn't create TestAutomationComRpc instance"); | ||
} else { | ||
|
||
if (_connectionId == 0){ //Running this plugin in process does not make any sense. It will not do proper test! | ||
result = _T("Running this plugin in process does not make any sense. It will not do proper test!"); | ||
} | ||
} | ||
return (result); | ||
} | ||
|
||
|
||
void TestAutomationComRpc::Deinitialize(PluginHost::IShell* service VARIABLE_IS_NOT_USED) | ||
{ | ||
ASSERT(_service == service); | ||
|
||
Exchange::TestAutomation::JComRpc::Unregister(*this); | ||
if (_implementation != nullptr) { | ||
RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId)); | ||
|
||
VARIABLE_IS_NOT_USED uint32_t result = _implementation->Release(); | ||
_implementation = nullptr; | ||
|
||
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); | ||
|
||
if(connection != nullptr){ | ||
connection->Terminate(); | ||
connection->Release(); | ||
} | ||
} | ||
|
||
_service->Release(); | ||
_service = nullptr; | ||
|
||
} | ||
|
||
string TestAutomationComRpc::Information() const | ||
{ | ||
return string(); | ||
} | ||
|
||
|
||
void TestAutomationComRpc::Deactivated(RPC::IRemoteConnection* connection) | ||
{ | ||
if (connection->Id() == _connectionId) { | ||
ASSERT(_service != nullptr); | ||
Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, | ||
PluginHost::IShell::DEACTIVATED, | ||
PluginHost::IShell::FAILURE)); | ||
} | ||
} | ||
|
||
Core::hresult TestAutomationComRpc::TestBigString(const uint32_t length) | ||
{ | ||
printf("TestAutomationComRpc::TestBigString -> Method called!\n"); | ||
ASSERT(_implementation != nullptr); | ||
const uint32_t stringLength = length * 1024; | ||
string bigString; | ||
bigString.resize(stringLength, 'a'); | ||
bigString.replace(0, 8, "testaaaa"); | ||
bigString.replace(bigString.length() - 8, 8, "testzzzz"); | ||
|
||
TRACE(Trace::Information, (_T("InP: Length Of The String Is " + std::to_string(bigString.length())))); | ||
TRACE(Trace::Information, (_T("InP: Content Of The String Is " + bigString))); | ||
|
||
return _implementation->BigStringTest(bigString); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2020 Metrological | ||
* | ||
* 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. | ||
*/ | ||
|
||
#ifndef __TESTAUTOMATIONCOMRPC_H | ||
#define __TESTAUTOMATIONCOMRPC_H | ||
|
||
|
||
#include "Module.h" | ||
#include <interfaces/ITestAutomation.h> | ||
#include <interfaces/json/JTestAutomationComRpc.h> | ||
|
||
namespace WPEFramework { | ||
namespace Plugin { | ||
|
||
class TestAutomationComRpc : public PluginHost::IPlugin, public Exchange::TestAutomation::IComRpc, public PluginHost::JSONRPC { | ||
public: | ||
TestAutomationComRpc(const TestAutomationComRpc&) = delete; | ||
TestAutomationComRpc& operator=(const TestAutomationComRpc&) = delete; | ||
|
||
TestAutomationComRpc() | ||
: _implementation(nullptr) | ||
, _connectionId(0) | ||
, _service(nullptr) | ||
|
||
{ | ||
} | ||
|
||
~TestAutomationComRpc() override | ||
{ | ||
} | ||
|
||
|
||
BEGIN_INTERFACE_MAP(TestAutomationComRpc) | ||
INTERFACE_ENTRY(PluginHost::IPlugin) | ||
INTERFACE_ENTRY(PluginHost::IDispatcher) | ||
INTERFACE_ENTRY(Exchange::TestAutomation::IComRpc) | ||
END_INTERFACE_MAP | ||
|
||
// ITestAutomationComRpc Methods | ||
Core::hresult TestBigString(const uint32_t length) override; | ||
|
||
// IPlugin methods | ||
// ------------------------------------------------------------------------------------------------------- | ||
const string Initialize(PluginHost::IShell* service) override; | ||
void Deinitialize(PluginHost::IShell* service) override; | ||
string Information() const override; | ||
|
||
private: | ||
void Deactivated(RPC::IRemoteConnection* connection); | ||
|
||
Exchange::TestAutomation::IComRpc::IComRpcInternal* _implementation; | ||
|
||
uint32_t _connectionId; | ||
PluginHost::IShell* _service; | ||
|
||
}; | ||
|
||
} // Namespace Plugin. | ||
}// namespace WPEFramework | ||
|
||
|
||
|
||
#endif // __TESTAUTOMATIONCOMRPC_H |
77 changes: 77 additions & 0 deletions
77
tests/TestAutomationComRpc/TestAutomationComRpcImplementation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2020 Metrological | ||
* | ||
* 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. | ||
*/ | ||
|
||
|
||
#include "Module.h" | ||
#include <interfaces/ITestAutomation.h> | ||
|
||
namespace WPEFramework { | ||
namespace Plugin { | ||
|
||
class TestAutomationComRpcImplementation : public Exchange::TestAutomation::IComRpc::IComRpcInternal { | ||
|
||
public: | ||
TestAutomationComRpcImplementation(const TestAutomationComRpcImplementation&) = delete; | ||
TestAutomationComRpcImplementation& operator=(const TestAutomationComRpcImplementation&) = delete; | ||
|
||
TestAutomationComRpcImplementation() | ||
{ | ||
} | ||
~TestAutomationComRpcImplementation() override = default; | ||
|
||
BEGIN_INTERFACE_MAP(TestAutomationComRpcImplementation) | ||
INTERFACE_ENTRY(Exchange::TestAutomation::IComRpc::IComRpcInternal) | ||
END_INTERFACE_MAP | ||
|
||
// IComRpcInternal Methods | ||
Core::hresult BigStringTest(const string& testString) override | ||
{ | ||
TRACE(Trace::Information, (_T("OOP: Length Of The String Is " + std::to_string(testString.length())))); | ||
string text = testString.c_str(); | ||
TRACE(Trace::Information, (_T("OOP: Content Of The String Is " + text))); | ||
|
||
uint32_t result = Core::ERROR_NONE; | ||
|
||
if (testString.length() >= 16){ | ||
string firstFourDigit = testString.substr(0, 8); | ||
string lastFourDigit = testString.substr((testString.length() - 8), 8); | ||
|
||
if (firstFourDigit == "testaaaa" && lastFourDigit == "testzzzz") { | ||
TRACE(Trace::Information, (_T("Verification Done For " + std::to_string(testString.length()/1024)))); | ||
} | ||
|
||
else { | ||
TRACE(Trace::Information, (_T("Verification FAILED For " + std::to_string(testString.length()/1024)))); | ||
result = Core::ERROR_GENERAL; | ||
} | ||
} | ||
else { | ||
|
||
TRACE(Trace::Information, (_T("String size is lower than 16"))); | ||
result = Core::ERROR_GENERAL; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
}; | ||
|
||
SERVICE_REGISTRATION(TestAutomationComRpcImplementation, 1, 0) | ||
} // namespace Plugin | ||
} // namespace WPEFramework |
16 changes: 16 additions & 0 deletions
16
tests/TestAutomationComRpc/TestAutomationComRpcPlugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "plugin.schema.json", | ||
"info": { | ||
"title": "TestAutomationComRpc Plugin", | ||
"callsign": "TestAutomationComRpc", | ||
"locator": "libWPEFrameworkTestAutomationComRpc.so", | ||
"status": "production", | ||
"description": "TestAutomationComRpc helps you to validate COMRPC messages via Automated Tests", | ||
"version": "1.0" | ||
}, | ||
|
||
"interface": { | ||
"$cppref": "{cppinterfacedir}/ITestAutomation.h" | ||
} | ||
} | ||
|
Oops, something went wrong.