@@ -33,7 +33,17 @@ namespace {
33
33
.Times (1 )
34
34
.RetiresOnSaturation ();
35
35
36
- EXPECT_CALL (*messagingProtocol, createMessage (_, name))
36
+ EXPECT_CALL (*messagingProtocol, createMessage (_, name, _))
37
+ .Times (1 )
38
+ .RetiresOnSaturation ();
39
+ }
40
+
41
+ void willSend (const std::string & topic, const std::string & name, const std::string & message) {
42
+ EXPECT_CALL (*mqttProcessor, send (topic, _, false ))
43
+ .Times (1 )
44
+ .RetiresOnSaturation ();
45
+
46
+ EXPECT_CALL (*messagingProtocol, createMessage (_, name, message))
37
47
.Times (1 )
38
48
.RetiresOnSaturation ();
39
49
}
@@ -70,27 +80,48 @@ namespace {
70
80
.RetiresOnSaturation ();
71
81
}
72
82
73
- void installWillFail ()
83
+ void installSetupWillFail ()
74
84
{
75
85
EXPECT_CALL (*installerAgent, installBundle (_))
76
86
.WillOnce (Return (sua::TechCode::InstallationFailed))
77
87
.RetiresOnSaturation ();
78
88
}
79
89
80
- void installWillSucceed ()
90
+ void installSetupWillSucceed ()
81
91
{
82
92
EXPECT_CALL (*installerAgent, installBundle (_))
83
93
.WillOnce (Return (sua::TechCode::OK))
84
94
.RetiresOnSaturation ();
85
95
}
86
96
97
+ void installStatusWillBeSuccess ()
98
+ {
99
+ EXPECT_CALL (*installerAgent, succeeded ())
100
+ .WillOnce (Return (true ))
101
+ .RetiresOnSaturation ();
102
+ }
103
+
87
104
void installProgressWillBe (const int value)
88
105
{
89
106
EXPECT_CALL (*installerAgent, getInstallProgress ())
90
107
.WillOnce (Return (value))
91
108
.RetiresOnSaturation ();
92
109
}
93
110
111
+ void installStatusWillBe (const bool value)
112
+ {
113
+ EXPECT_CALL (*installerAgent, installing ())
114
+ .WillOnce (Return (value))
115
+ .RetiresOnSaturation ();
116
+ }
117
+
118
+ void lastErrorWillBe (const std::string & text)
119
+ {
120
+ EXPECT_CALL (*installerAgent, getLastError ())
121
+ .WillOnce (Return (text))
122
+ .RetiresOnSaturation ();
123
+ }
124
+
94
125
sua::Context & ctx () {
95
126
return sua.context ();
96
127
}
@@ -232,7 +263,7 @@ namespace {
232
263
ctx ().stateMachine ->handleEvent (sua::FotaEvent::Start);
233
264
}
234
265
235
- TEST_F (TestSelfUpdateScenarios, receivesUpdateRequestAndInstallFails_sendsInstallFailed )
266
+ TEST_F (TestSelfUpdateScenarios, receivesUpdateRequestAndInstallSetupFails_sendsInstallFailed )
236
267
{
237
268
willTransitTo (" Uninitialized" );
238
269
currentVersionIs (" 1.0" );
@@ -249,7 +280,8 @@ namespace {
249
280
willSend (" selfupdate/desiredstatefeedback" , " downloaded" );
250
281
251
282
willTransitTo (" Installing" );
252
- installWillFail ();
283
+ installSetupWillFail ();
284
+ lastErrorWillBe (" test" );
253
285
willSend (" selfupdate/desiredstatefeedback" , " installFailed" );
254
286
255
287
willTransitTo (" Failed" );
@@ -278,11 +310,14 @@ namespace {
278
310
willSend (" selfupdate/desiredstatefeedback" , " downloaded" );
279
311
280
312
willTransitTo (" Installing" );
281
- installWillSucceed ();
313
+ installSetupWillSucceed ();
282
314
// gmock is checking expecations in reverse order
283
- installProgressWillBe (100 );
315
+ installStatusWillBe (false ); // completed (!installing)
316
+ installStatusWillBe (true ); // installing
317
+ installStatusWillBe (true ); // installing
318
+ installProgressWillBe (99 );
284
319
installProgressWillBe (50 );
285
- installProgressWillBe ( 0 );
320
+ installStatusWillBeSuccess ( );
286
321
willSend (" selfupdate/desiredstatefeedback" , " installing" );
287
322
willSend (" selfupdate/desiredstatefeedback" , " installing" );
288
323
willSend (" selfupdate/desiredstatefeedback" , " installed" );
0 commit comments