MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / frame030b

Function frame030b

framework/test/gtest/StaticBundleTest.cpp:109–150  ·  view source on GitHub ↗

Stop libB and check for correct events

Source from the content-addressed store, hash-verified

107
108 // Stop libB and check for correct events
109 void
110 frame030b(BundleContext context, TestBundleListener& listener)
111 {
112 auto bundleB = cppmicroservices::testing::GetBundle("TestBundleB", context);
113 // Test for non-null bundle
114 ASSERT_TRUE(bundleB);
115
116 auto bundleImportedByB = cppmicroservices::testing::GetBundle("TestBundleImportedByB", context);
117 // Test for non-null bundle
118 ASSERT_TRUE(bundleImportedByB);
119
120 std::vector<ServiceReferenceU> refs = context.GetServiceReferences("cppmicroservices::TestBundleBService");
121 // Test for first valid service reference
122 ASSERT_TRUE(refs.front());
123 // Test for second valid service reference
124 ASSERT_TRUE(refs.back());
125
126 EXPECT_NO_THROW(bundleB.Stop()) << "Stop bundle exception";
127 // Test for stopped state
128 ASSERT_EQ(bundleB.GetState(), Bundle::STATE_RESOLVED);
129
130 EXPECT_NO_THROW(bundleImportedByB.Stop()) << "Stop bundle exception";
131 // Test for stopped state
132 ASSERT_EQ(bundleImportedByB.GetState(), Bundle::STATE_RESOLVED);
133
134 std::vector<BundleEvent> pEvts;
135 pEvts.push_back(BundleEvent(BundleEvent::BUNDLE_STOPPING, bundleB));
136 pEvts.push_back(BundleEvent(BundleEvent::BUNDLE_STOPPED, bundleB));
137 pEvts.push_back(BundleEvent(BundleEvent::BUNDLE_STOPPING, bundleImportedByB));
138 pEvts.push_back(BundleEvent(BundleEvent::BUNDLE_STOPPED, bundleImportedByB));
139
140 std::vector<ServiceEvent> seEvts;
141 seEvts.push_back(ServiceEvent(ServiceEvent::SERVICE_UNREGISTERING, refs.front()));
142 seEvts.push_back(ServiceEvent(ServiceEvent::SERVICE_UNREGISTERING, refs.back()));
143
144 bool relaxed = false;
145#ifndef US_BUILD_SHARED_LIBS
146 relaxed = true;
147#endif
148 // Test for unexpected events
149 ASSERT_TRUE(listener.CheckListenerEvents(pEvts, seEvts, relaxed));
150 }
151
152// Uninstall libB and check for correct events
153#ifdef US_BUILD_SHARED_LIBS

Callers 1

TESTFunction · 0.85

Calls 9

GetBundleFunction · 0.85
frontMethod · 0.80
backMethod · 0.80
CheckListenerEventsMethod · 0.80
BundleEventClass · 0.50
ServiceEventClass · 0.50
GetServiceReferencesMethod · 0.45
StopMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected