1+ /*
2+ * Copyright (c) 2015, Intel Corporation
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without modification,
6+ * are permitted provided that the following conditions are met:
7+ *
8+ * 1. Redistributions of source code must retain the above copyright notice, this
9+ * list of conditions and the following disclaimer.
10+ *
11+ * 2. Redistributions in binary form must reproduce the above copyright notice,
12+ * this list of conditions and the following disclaimer in the documentation and/or
13+ * other materials provided with the distribution.
14+ *
15+ * 3. Neither the name of the copyright holder nor the names of its contributors
16+ * may be used to endorse or promote products derived from this software without
17+ * specific prior written permission.
18+ *
19+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+ */
30+
31+ #include " Config.hpp"
32+ #include " ParameterFramework.hpp"
33+ #include < SubsystemObject.h>
34+ #include < IntrospectionEntryPoint.h>
35+ #include " Test.hpp"
36+ #include < catch.hpp>
37+ #include < string>
38+
39+ using std::string;
40+
41+ namespace parameterFramework
42+ {
43+
44+ struct BoolPF : public ParameterFramework
45+ {
46+ BoolPF ()
47+ : ParameterFramework{ std::move (createConfig ()) } {}
48+
49+ /* * Set the boolean parameter value within the "Conf" configuration,
50+ * which is always applicable. */
51+ void setParameterValue (bool value)
52+ {
53+ std::string valueStr = value ? " 1" : " 0" ;
54+ setConfigurationParameter (" Domain" , " Conf" , " /test/test/param" , valueStr);
55+ }
56+
57+ private:
58+ static Config createConfig ()
59+ {
60+ Config config;
61+ config.instances = R"( <BooleanParameter Name="param" Mapping="Object"/>)" ;
62+ config.plugins = { { " " , {" introspection-subsystem" } } };
63+ config.subsystemType = " INTROSPECTION" ;
64+
65+ config.domains = R"( <ConfigurableDomain Name="Domain">
66+ <Configurations>
67+ <Configuration Name="Conf">
68+ <CompoundRule Type="All"/>
69+ </Configuration>
70+ </Configurations>
71+
72+ <ConfigurableElements>
73+ <ConfigurableElement Path="/test/test/param"/>
74+ </ConfigurableElements>
75+
76+ <Settings>
77+ <Configuration Name="Conf">
78+ <ConfigurableElement Path="/test/test/param">
79+ <BooleanParameter Name="param">0</BooleanParameter>
80+ </ConfigurableElement>
81+ </Configuration>
82+ </Settings>
83+ </ConfigurableDomain>)" ;
84+
85+ return config;
86+ }
87+ };
88+
89+ SCENARIO_METHOD (BoolPF, " Auto sync" ) {
90+ GIVEN (" Tuning is off" ) {
91+
92+ REQUIRE_NOTHROW (start ());
93+ CHECK_FALSE (isTuningModeOn ());
94+
95+ /* Parameter value should be false according to the settings */
96+ CHECK_FALSE (parameterFramework::introspectionSubsystem::getParameterValue ());
97+
98+ WHEN (" Autosync is on" ) {
99+ CHECK_NOTHROW (setAutoSync (true ));
100+
101+ THEN (" Sync is done when a parameter is set" ) {
102+ CHECK_NOTHROW (setParameterValue (true ));
103+ CHECK (parameterFramework::introspectionSubsystem::getParameterValue ());
104+ }
105+ }
106+ WHEN (" Autosync is off" ) {
107+ CHECK_NOTHROW (setAutoSync (false ));
108+
109+ THEN (" Sync is done when auto-sync is activated" ) {
110+
111+ CHECK_NOTHROW (setParameterValue (true ));
112+
113+ /* Parameter shall have not been changed yet*/
114+ CHECK_FALSE (parameterFramework::introspectionSubsystem::getParameterValue ());
115+
116+ CHECK_NOTHROW (setAutoSync (true ));
117+
118+ /* Auto-sync is on, parameter shall have been changed */
119+ CHECK (parameterFramework::introspectionSubsystem::getParameterValue ());
120+ }
121+ }
122+ }
123+ }
124+
125+ }
0 commit comments