Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xs-test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patrick Chen
xs-test
Commits
337ed1f3
Commit
337ed1f3
authored
Aug 28, 2018
by
Patrick Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix listen event bug
parent
7ad112c4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
greeting.cc
example/greeting.cc
+2
-1
greeting.json
example/greeting.json
+5
-2
Tester.cc
src/test/Tester.cc
+5
-3
No files found.
example/greeting.cc
View file @
337ed1f3
...
@@ -9,9 +9,10 @@ int main()
...
@@ -9,9 +9,10 @@ int main()
{
{
xs
::
ExchangeServer
server
(
"greeting"
,
{},
{},
0
,
nullptr
);
xs
::
ExchangeServer
server
(
"greeting"
,
{},
{},
0
,
nullptr
);
server
.
onCmd
(
server
.
onCmd
(
"Get
Greeting
Message"
,
"GetMessage"
,
[
&
server
](
const
std
::
string
&
,
const
std
::
string
&
)
{
[
&
server
](
const
std
::
string
&
,
const
std
::
string
&
)
{
const
auto
name
=
server
.
runCmd
(
"GetName"
,
""
);
const
auto
name
=
server
.
runCmd
(
"GetName"
,
""
);
server
.
postEvent
(
"NotifyGetMessage"
,
""
);
return
"Hello, "
+
name
+
"!"
;
return
"Hello, "
+
name
+
"!"
;
}
}
);
);
...
...
example/greeting.json
View file @
337ed1f3
...
@@ -3,14 +3,17 @@
...
@@ -3,14 +3,17 @@
{
{
"command"
:
"GetName"
,
"command"
:
"GetName"
,
"response"
:
"Master"
"response"
:
"Master"
},
{
"event"
:
"NotifyGetMessage"
}
}
],
],
"script"
:
[
"script"
:
[
{
{
"command"
:
"Get
Greeting
Message"
,
"command"
:
"GetMessage"
,
"expect"
:
"Hello, Master!"
,
"expect"
:
"Hello, Master!"
,
"runs"
:
[
"GetName"
],
"runs"
:
[
"GetName"
],
"posts"
:
[]
"posts"
:
[
"NotifyGetMessage"
]
}
}
]
]
}
}
src/test/Tester.cc
View file @
337ed1f3
...
@@ -106,9 +106,6 @@ std::string Tester::onCommand(const std::string& name, const std::string& params
...
@@ -106,9 +106,6 @@ std::string Tester::onCommand(const std::string& name, const std::string& params
void
Tester
::
onEvent
(
const
std
::
string
&
name
,
const
std
::
string
&
params
)
noexcept
void
Tester
::
onEvent
(
const
std
::
string
&
name
,
const
std
::
string
&
params
)
noexcept
{
{
const
auto
found
=
acceptEvents_
.
find
(
name
);
const
auto
*
service
=
std
::
get
<
1
>
(
*
found
);
receivedEventCount_
[
name
]
++
;
receivedEventCount_
[
name
]
++
;
}
}
...
@@ -118,6 +115,11 @@ void Tester::run() noexcept
...
@@ -118,6 +115,11 @@ void Tester::run() noexcept
resetCounters
();
resetCounters
();
const
auto
response
=
server_
.
runCmd
(
expectation
.
name_
,
""
);
const
auto
response
=
server_
.
runCmd
(
expectation
.
name_
,
""
);
// wait 100ms for upcoming events
using
namespace
std
::
chrono_literals
;
std
::
this_thread
::
sleep_for
(
100
ms
);
const
auto
report
=
createReport
(
response
,
expectation
);
const
auto
report
=
createReport
(
response
,
expectation
);
if
(
report
.
pass
)
{
if
(
report
.
pass
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment