~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to tests/algorithms/qgsproject/projecttest.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
     projecttest.h
 
3
     --------------------------------------
 
4
    Date                 : Sun Sep 16 12:20:49 AKDT 2007
 
5
    Copyright            : (C) 2007 by Gary E. Sherman
 
6
    Email                : sherman at mrcc dot com
 
7
 ***************************************************************************
 
8
 *                                                                         *
 
9
 *   This program is free software; you can redistribute it and/or modify  *
 
10
 *   it under the terms of the GNU General Public License as published by  *
 
11
 *   the Free Software Foundation; either version 2 of the License, or     *
 
12
 *   (at your option) any later version.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
1
15
/**
2
16
 
3
17
 @file projecttst.h
29
43
   Although the last two may be difficult to test for since qgis won't be running.
30
44
 
31
45
*/
32
 
class ProjectTest : public CppUnit::TestFixture 
33
 
 
46
class ProjectTest : public CppUnit::TestFixture
 
47
{
34
48
    CPPUNIT_TEST_SUITE( ProjectTest );
35
49
 
36
50
    CPPUNIT_TEST( testFileName );
47
61
 
48
62
    CPPUNIT_TEST_SUITE_END();
49
63
 
50
 
  public: 
 
64
  public:
51
65
 
52
 
    /** 
 
66
    /**
53
67
        Setup the common test members, etc
54
68
    */
55
69
    void setUp()
56
70
    {
57
 
        mFile = "test.project";
58
 
        mTitle = "test title";
59
 
        mScope = "project_test";
60
 
 
61
 
        mNumValueKey = "/values/myNum";
62
 
 
63
 
        mDoubleValueKey = "/values/myDouble";
64
 
 
65
 
        mBoolValueKey = "/values/myBool";
66
 
 
67
 
        mStringValueKey = "/values/very/nested/myString";
68
 
 
69
 
        mStringListValueKey = "/values/myStrings/myStringlist";
70
 
 
71
 
 
72
 
        mNumValueConst = 42;
73
 
 
74
 
        mDoubleValueConst = 12345.6789;
75
 
 
76
 
        mBoolValueConst = true;
77
 
 
78
 
        mStringValueConst = "Test String";
79
 
 
80
 
        mStringListValueConst += "first";
81
 
        mStringListValueConst += "second";
82
 
        mStringListValueConst += "third";
 
71
      mFile = "test.project";
 
72
      mTitle = "test title";
 
73
      mScope = "project_test";
 
74
 
 
75
      mNumValueKey = "/values/myNum";
 
76
 
 
77
      mDoubleValueKey = "/values/myDouble";
 
78
 
 
79
      mBoolValueKey = "/values/myBool";
 
80
 
 
81
      mStringValueKey = "/values/very/nested/myString";
 
82
 
 
83
      mStringListValueKey = "/values/myStrings/myStringlist";
 
84
 
 
85
 
 
86
      mNumValueConst = 42;
 
87
 
 
88
      mDoubleValueConst = 12345.6789;
 
89
 
 
90
      mBoolValueConst = true;
 
91
 
 
92
      mStringValueConst = "Test String";
 
93
 
 
94
      mStringListValueConst += "first";
 
95
      mStringListValueConst += "second";
 
96
      mStringListValueConst += "third";
83
97
    } // setUp
84
98
 
85
 
    
 
99
 
86
100
 
87
101
    void testFileName()
88
102
    {
89
 
        QgsProject::instance()->dirty( false );
90
 
        QgsProject::instance()->filename( mFile );
 
103
      QgsProject::instance()->dirty( false );
 
104
      QgsProject::instance()->setFileName( mFile );
91
105
 
92
 
        CPPUNIT_ASSERT( mFile == QgsProject::instance()->filename() );
93
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
 
106
      CPPUNIT_ASSERT( mFile == QgsProject::instance()->fileName() );
 
107
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
94
108
    } // testFileName
95
109
 
96
 
    
 
110
 
97
111
 
98
112
    void testTitle()
99
113
    {
100
 
        QgsProject::instance()->dirty( false );
101
 
        QgsProject::instance()->title( mTitle );
 
114
      QgsProject::instance()->dirty( false );
 
115
      QgsProject::instance()->title( mTitle );
102
116
 
103
 
        CPPUNIT_ASSERT( mTitle == QgsProject::instance()->title() );
104
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
 
117
      CPPUNIT_ASSERT( mTitle == QgsProject::instance()->title() );
 
118
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
105
119
    } // testTitle
106
120
 
107
121
 
108
122
    void testMapUnits()
109
123
    {
110
 
        QgsProject::instance()->dirty( false );
111
 
        QgsProject::instance()->mapUnits( QGis::METERS );
112
 
        CPPUNIT_ASSERT( QGis::METERS == QgsProject::instance()->mapUnits() );
113
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
114
 
 
115
 
        QgsProject::instance()->dirty( false );
116
 
        QgsProject::instance()->mapUnits( QGis::FEET );
117
 
        CPPUNIT_ASSERT( QGis::FEET == QgsProject::instance()->mapUnits() );
118
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
119
 
 
120
 
        QgsProject::instance()->dirty( false );
121
 
        QgsProject::instance()->mapUnits( QGis::DEGREES );
122
 
        CPPUNIT_ASSERT( QGis::DEGREES == QgsProject::instance()->mapUnits() );
123
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
 
124
      QgsProject::instance()->dirty( false );
 
125
      QgsProject::instance()->mapUnits( QGis::Meters );
 
126
      CPPUNIT_ASSERT( QGis::Meters == QgsProject::instance()->mapUnits() );
 
127
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
128
 
 
129
      QgsProject::instance()->dirty( false );
 
130
      QgsProject::instance()->mapUnits( QGis::Feet );
 
131
      CPPUNIT_ASSERT( QGis::Feet == QgsProject::instance()->mapUnits() );
 
132
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
133
 
 
134
      QgsProject::instance()->dirty( false );
 
135
      QgsProject::instance()->mapUnits( QGis::Degrees );
 
136
      CPPUNIT_ASSERT( QGis::Degrees == QgsProject::instance()->mapUnits() );
 
137
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
124
138
    } // testMapUnits
125
139
 
126
140
 
127
141
 
128
142
    void testDirtyFlag()
129
143
    {
130
 
        QgsProject::instance()->dirty( true );
131
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
 
144
      QgsProject::instance()->dirty( true );
 
145
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
132
146
 
133
 
        QgsProject::instance()->dirty( false );
134
 
        CPPUNIT_ASSERT( ! QgsProject::instance()->dirty() );
 
147
      QgsProject::instance()->dirty( false );
 
148
      CPPUNIT_ASSERT( ! QgsProject::instance()->isDirty() );
135
149
    } // testDirtyFlag
136
150
 
137
 
    
 
151
 
138
152
    /**
139
153
       Reading entries that are known not to exist should fail and use default
140
154
       values.
141
155
     */
142
156
    void readNullEntries()
143
157
    {
144
 
        bool status;
145
 
 
146
 
        bool b = QgsProject::instance()->readBoolEntry( mScope, mBoolValueKey, false, &status );
147
 
        CPPUNIT_ASSERT( false == b && ! status );
148
 
 
149
 
        int i = QgsProject::instance()->readNumEntry( mScope, mNumValueKey, 13, &status );
150
 
        CPPUNIT_ASSERT( 13 == i && ! status );
151
 
 
152
 
        double d = QgsProject::instance()->readDoubleEntry( mScope, mDoubleValueKey, 99.0, &status );
153
 
        CPPUNIT_ASSERT( 99.0 == d && ! status );
154
 
 
155
 
        QString s = QgsProject::instance()->readEntry( mScope, mStringValueKey, "FOO", &status );
156
 
        CPPUNIT_ASSERT( "FOO" == s && ! status );
157
 
 
158
 
        QStringList sl = QgsProject::instance()->readListEntry( mScope, mStringListValueKey, &status );
159
 
        CPPUNIT_ASSERT( sl.empty() && ! status );
 
158
      bool status;
 
159
 
 
160
      bool b = QgsProject::instance()->readBoolEntry( mScope, mBoolValueKey, false, &status );
 
161
      CPPUNIT_ASSERT( false == b && ! status );
 
162
 
 
163
      int i = QgsProject::instance()->readNumEntry( mScope, mNumValueKey, 13, &status );
 
164
      CPPUNIT_ASSERT( 13 == i && ! status );
 
165
 
 
166
      double d = QgsProject::instance()->readDoubleEntry( mScope, mDoubleValueKey, 99.0, &status );
 
167
      CPPUNIT_ASSERT( 99.0 == d && ! status );
 
168
 
 
169
      QString s = QgsProject::instance()->readEntry( mScope, mStringValueKey, "FOO", &status );
 
170
      CPPUNIT_ASSERT( "FOO" == s && ! status );
 
171
 
 
172
      QStringList sl = QgsProject::instance()->readListEntry( mScope, mStringListValueKey, &status );
 
173
      CPPUNIT_ASSERT( sl.empty() && ! status );
160
174
 
161
175
    } // readNullEntries
162
176
 
164
178
    /** check that writing entries works */
165
179
    void testWriteEntries()
166
180
    {
167
 
        QgsProject::instance()->dirty( false );
168
 
        CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mBoolValueKey, mBoolValueConst ) );
169
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
170
 
 
171
 
        QgsProject::instance()->dirty( false );
172
 
        CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mNumValueKey, mNumValueConst ) );
173
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
174
 
 
175
 
        QgsProject::instance()->dirty( false );
176
 
        CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mDoubleValueKey, mDoubleValueConst ) );
177
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
178
 
 
179
 
        QgsProject::instance()->dirty( false );
180
 
        CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mStringValueKey, mStringValueConst ) );
181
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
182
 
 
183
 
        QgsProject::instance()->dirty( false );
184
 
        CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mStringListValueKey, mStringListValueConst ) );
185
 
        CPPUNIT_ASSERT( QgsProject::instance()->dirty() );
186
 
 
187
 
 
188
 
        bool status;
189
 
 
190
 
        int i = QgsProject::instance()->readNumEntry( mScope, mNumValueKey, 13, &status );
191
 
        CPPUNIT_ASSERT( mNumValueConst == i && status );
192
 
 
193
 
        bool b = QgsProject::instance()->readBoolEntry( mScope, mBoolValueKey, false, &status );
194
 
        CPPUNIT_ASSERT( mBoolValueConst == b && status );
195
 
 
196
 
        double d = QgsProject::instance()->readDoubleEntry( mScope, mDoubleValueKey, 99.0, &status );
197
 
        CPPUNIT_ASSERT( mDoubleValueConst == d && status );
198
 
 
199
 
        QString s = QgsProject::instance()->readEntry( mScope, mStringValueKey, "FOO", &status );
200
 
        CPPUNIT_ASSERT( mStringValueConst == s && status );
201
 
 
202
 
        QStringList sl = QgsProject::instance()->readListEntry( mScope, mStringListValueKey, &status );
203
 
        CPPUNIT_ASSERT( mStringListValueConst == sl && status );
 
181
      QgsProject::instance()->dirty( false );
 
182
      CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mBoolValueKey, mBoolValueConst ) );
 
183
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
184
 
 
185
      QgsProject::instance()->dirty( false );
 
186
      CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mNumValueKey, mNumValueConst ) );
 
187
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
188
 
 
189
      QgsProject::instance()->dirty( false );
 
190
      CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mDoubleValueKey, mDoubleValueConst ) );
 
191
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
192
 
 
193
      QgsProject::instance()->dirty( false );
 
194
      CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mStringValueKey, mStringValueConst ) );
 
195
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
196
 
 
197
      QgsProject::instance()->dirty( false );
 
198
      CPPUNIT_ASSERT( QgsProject::instance()->writeEntry( mScope, mStringListValueKey, mStringListValueConst ) );
 
199
      CPPUNIT_ASSERT( QgsProject::instance()->isDirty() );
 
200
 
 
201
 
 
202
      bool status;
 
203
 
 
204
      int i = QgsProject::instance()->readNumEntry( mScope, mNumValueKey, 13, &status );
 
205
      CPPUNIT_ASSERT( mNumValueConst == i && status );
 
206
 
 
207
      bool b = QgsProject::instance()->readBoolEntry( mScope, mBoolValueKey, false, &status );
 
208
      CPPUNIT_ASSERT( mBoolValueConst == b && status );
 
209
 
 
210
      double d = QgsProject::instance()->readDoubleEntry( mScope, mDoubleValueKey, 99.0, &status );
 
211
      CPPUNIT_ASSERT( mDoubleValueConst == d && status );
 
212
 
 
213
      QString s = QgsProject::instance()->readEntry( mScope, mStringValueKey, "FOO", &status );
 
214
      CPPUNIT_ASSERT( mStringValueConst == s && status );
 
215
 
 
216
      QStringList sl = QgsProject::instance()->readListEntry( mScope, mStringListValueKey, &status );
 
217
      CPPUNIT_ASSERT( mStringListValueConst == sl && status );
204
218
 
205
219
    } // testWriteEntries
206
220
 
207
221
    void testXML()
208
222
    {  // write out the state, clear the project, reload it, and see if we got
209
 
       // everything back
210
 
        CPPUNIT_ASSERT( QgsProject::instance()->write() );
211
 
 
212
 
        QgsProject::instance()->clearProperties();
213
 
 
214
 
        try
215
 
        {
216
 
            CPPUNIT_ASSERT( QgsProject::instance()->read() );
217
 
        }
218
 
        catch( QgsException & e )
219
 
        {
220
 
            // since we're not running the full application, this exception is
221
 
            // expected, so we can safely ignore it
222
 
 
223
 
            qDebug( "%s:%d caught expected exception %s", __FILE__, __LINE__, e.what() );
224
 
 
225
 
        }
226
 
 
227
 
        bool status;
228
 
 
229
 
        bool b = QgsProject::instance()->readBoolEntry( mScope, mBoolValueKey, false, &status );
230
 
        CPPUNIT_ASSERT( mBoolValueConst == b && status );
231
 
 
232
 
        int i = QgsProject::instance()->readNumEntry( mScope, mNumValueKey, 13, &status );
233
 
        CPPUNIT_ASSERT( mNumValueConst == i && status );
234
 
 
235
 
        double d = QgsProject::instance()->readDoubleEntry( mScope, mDoubleValueKey, 99.0, &status );
236
 
        CPPUNIT_ASSERT( mDoubleValueConst == d && status );
237
 
 
238
 
        QString s = QgsProject::instance()->readEntry( mScope, mStringValueKey, "FOO", &status );
239
 
        CPPUNIT_ASSERT( mStringValueConst == s && status );
240
 
 
241
 
        QStringList sl = QgsProject::instance()->readListEntry( mScope, mStringListValueKey, &status );
242
 
        CPPUNIT_ASSERT( mStringListValueConst == sl && status );
 
223
      // everything back
 
224
      CPPUNIT_ASSERT( QgsProject::instance()->write() );
 
225
 
 
226
      QgsProject::instance()->clearProperties();
 
227
 
 
228
      try
 
229
      {
 
230
        CPPUNIT_ASSERT( QgsProject::instance()->read() );
 
231
      }
 
232
      catch ( QgsException & e )
 
233
      {
 
234
        // since we're not running the full application, this exception is
 
235
        // expected, so we can safely ignore it
 
236
 
 
237
        qDebug( "%s:%d caught expected exception %s", __FILE__, __LINE__, e.what() );
 
238
 
 
239
      }
 
240
 
 
241
      bool status;
 
242
 
 
243
      bool b = QgsProject::instance()->readBoolEntry( mScope, mBoolValueKey, false, &status );
 
244
      CPPUNIT_ASSERT( mBoolValueConst == b && status );
 
245
 
 
246
      int i = QgsProject::instance()->readNumEntry( mScope, mNumValueKey, 13, &status );
 
247
      CPPUNIT_ASSERT( mNumValueConst == i && status );
 
248
 
 
249
      double d = QgsProject::instance()->readDoubleEntry( mScope, mDoubleValueKey, 99.0, &status );
 
250
      CPPUNIT_ASSERT( mDoubleValueConst == d && status );
 
251
 
 
252
      QString s = QgsProject::instance()->readEntry( mScope, mStringValueKey, "FOO", &status );
 
253
      CPPUNIT_ASSERT( mStringValueConst == s && status );
 
254
 
 
255
      QStringList sl = QgsProject::instance()->readListEntry( mScope, mStringListValueKey, &status );
 
256
      CPPUNIT_ASSERT( mStringListValueConst == sl && status );
243
257
 
244
258
//         qDebug( "%s:%d testXML after read" );
245
259
 
249
263
 
250
264
    void testRemoveEntry()
251
265
    {
252
 
        // presume that testWriteEntries() already invoked so that properties are set
253
 
 
254
 
        CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mBoolValueKey ) );
255
 
        CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mNumValueKey ) );
256
 
        CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mDoubleValueKey ) );
257
 
        CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mStringValueKey ) );
258
 
        CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mStringListValueKey ) );
259
 
 
260
 
        // since we've removed everything, re-run this test to verify that
261
 
        readNullEntries();
262
 
        
 
266
      // presume that testWriteEntries() already invoked so that properties are set
 
267
 
 
268
      CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mBoolValueKey ) );
 
269
      CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mNumValueKey ) );
 
270
      CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mDoubleValueKey ) );
 
271
      CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mStringValueKey ) );
 
272
      CPPUNIT_ASSERT( QgsProject::instance()->removeEntry( mScope, mStringListValueKey ) );
 
273
 
 
274
      // since we've removed everything, re-run this test to verify that
 
275
      readNullEntries();
 
276
 
263
277
    } // testRemoveEntry
264
278
 
265
279
 
266
280
    void testClearProperties()
267
281
    {   // rebuild the properties deleted in testRemoveEntry()
268
 
        testWriteEntries();
269
 
 
270
 
        // remove all in one fell swoop
271
 
        QgsProject::instance()->clearProperties();
272
 
 
273
 
        // since we've removed everything, re-run this test to verify that
274
 
        readNullEntries();
 
282
      testWriteEntries();
 
283
 
 
284
      // remove all in one fell swoop
 
285
      QgsProject::instance()->clearProperties();
 
286
 
 
287
      // since we've removed everything, re-run this test to verify that
 
288
      readNullEntries();
275
289
    } // testClearProperties
276
290
 
277
291
 
278
 
    /** test entryList() 
 
292
    /** test entryList()
279
293
     */
280
294
    void testEntryList()
281
295
    {
282
 
        // at first the entry list should be empty
283
 
        QStringList entries = QgsProject::instance()->entryList( mScope, "/foo" );
284
 
 
285
 
        CPPUNIT_ASSERT( entries.isEmpty() );
286
 
 
287
 
        QgsProject::instance()->writeEntry( mScope, "/foo/bar", "one" );
288
 
        QgsProject::instance()->writeEntry( mScope, "/foo/baz", "two" );
289
 
        QgsProject::instance()->writeEntry( mScope, "/foo/quux", "three" );
290
 
 
291
 
        QgsProject::instance()->writeEntry( mScope, "/foo/xmmy/blah", "four" );
292
 
        QgsProject::instance()->writeEntry( mScope, "/foo/xmmy/bogus", "five" );
293
 
 
294
 
        QgsProject::instance()->dumpProperties();
295
 
 
296
 
        // So entrylist for /foo should return "bar", "baz", and "quux" but
297
 
        // NOT "xmmy".  Nor should it contain any key values.
298
 
 
299
 
        entries = QgsProject::instance()->entryList( mScope, "/foo" );
300
 
 
301
 
        cerr << "entries: ";
302
 
        for ( QStringList::iterator i = entries.begin();
303
 
              i != entries.end();
304
 
              ++i )
305
 
        {
306
 
            cerr << *i << " ";
307
 
        }
308
 
        cerr << "\n";
309
 
 
310
 
        CPPUNIT_ASSERT( entries.find( "bar" ) != entries.end() );
311
 
        CPPUNIT_ASSERT( entries.find( "baz" ) != entries.end() );
312
 
        CPPUNIT_ASSERT( entries.find( "quux" ) != entries.end() );
313
 
 
314
 
        CPPUNIT_ASSERT( entries.find( "xmmy" ) == entries.end() );
315
 
        CPPUNIT_ASSERT( entries.find( "blah" ) == entries.end() );
316
 
        CPPUNIT_ASSERT( entries.find( "bogus" ) == entries.end() );
317
 
 
318
 
        CPPUNIT_ASSERT( entries.find( "one" ) == entries.end() );
319
 
        CPPUNIT_ASSERT( entries.find( "two" ) == entries.end() );
320
 
        CPPUNIT_ASSERT( entries.find( "three" ) == entries.end() );
321
 
        CPPUNIT_ASSERT( entries.find( "four" ) == entries.end() );
322
 
        CPPUNIT_ASSERT( entries.find( "five" ) == entries.end() );
 
296
      // at first the entry list should be empty
 
297
      QStringList entries = QgsProject::instance()->entryList( mScope, "/foo" );
 
298
 
 
299
      CPPUNIT_ASSERT( entries.isEmpty() );
 
300
 
 
301
      QgsProject::instance()->writeEntry( mScope, "/foo/bar", "one" );
 
302
      QgsProject::instance()->writeEntry( mScope, "/foo/baz", "two" );
 
303
      QgsProject::instance()->writeEntry( mScope, "/foo/quux", "three" );
 
304
 
 
305
      QgsProject::instance()->writeEntry( mScope, "/foo/xmmy/blah", "four" );
 
306
      QgsProject::instance()->writeEntry( mScope, "/foo/xmmy/bogus", "five" );
 
307
 
 
308
      QgsProject::instance()->dumpProperties();
 
309
 
 
310
      // So entrylist for /foo should return "bar", "baz", and "quux" but
 
311
      // NOT "xmmy".  Nor should it contain any key values.
 
312
 
 
313
      entries = QgsProject::instance()->entryList( mScope, "/foo" );
 
314
 
 
315
      cerr << "entries: ";
 
316
      for ( QStringList::iterator i = entries.begin();
 
317
            i != entries.end();
 
318
            ++i )
 
319
      {
 
320
        cerr << *i << " ";
 
321
      }
 
322
      cerr << "\n";
 
323
 
 
324
      CPPUNIT_ASSERT( entries.find( "bar" ) != entries.end() );
 
325
      CPPUNIT_ASSERT( entries.find( "baz" ) != entries.end() );
 
326
      CPPUNIT_ASSERT( entries.find( "quux" ) != entries.end() );
 
327
 
 
328
      CPPUNIT_ASSERT( entries.find( "xmmy" ) == entries.end() );
 
329
      CPPUNIT_ASSERT( entries.find( "blah" ) == entries.end() );
 
330
      CPPUNIT_ASSERT( entries.find( "bogus" ) == entries.end() );
 
331
 
 
332
      CPPUNIT_ASSERT( entries.find( "one" ) == entries.end() );
 
333
      CPPUNIT_ASSERT( entries.find( "two" ) == entries.end() );
 
334
      CPPUNIT_ASSERT( entries.find( "three" ) == entries.end() );
 
335
      CPPUNIT_ASSERT( entries.find( "four" ) == entries.end() );
 
336
      CPPUNIT_ASSERT( entries.find( "five" ) == entries.end() );
323
337
    }
324
338
 
325
339
 
326
340
    void testSubkeyList()
327
341
    {
328
 
        // at first the entry list should be empty -- "bogus" known to be empty
329
 
        QStringList entries = QgsProject::instance()->subkeyList( mScope, "/bogus" );
330
 
        cerr << "subkeys: ";
331
 
        for ( QStringList::iterator i = entries.begin();
332
 
              i != entries.end();
333
 
              ++i )
334
 
        {
335
 
            cerr << *i << " ";
336
 
        }
337
 
        cerr << "\n";
338
 
 
339
 
        CPPUNIT_ASSERT( entries.isEmpty() );
340
 
 
341
 
        // So subkeylist for /foo should return only "xmmy".
342
 
 
343
 
        entries = QgsProject::instance()->subkeyList( mScope, "/foo" );
344
 
 
345
 
        cerr << "subkeys: ";
346
 
        for ( QStringList::iterator i = entries.begin();
347
 
              i != entries.end();
348
 
              ++i )
349
 
        {
350
 
            cerr << *i << " ";
351
 
        }
352
 
        cerr << "\n";
353
 
 
354
 
        CPPUNIT_ASSERT( entries.find( "bar" ) == entries.end() );
355
 
        CPPUNIT_ASSERT( entries.find( "baz" ) == entries.end() );
356
 
        CPPUNIT_ASSERT( entries.find( "quux" ) == entries.end() );
357
 
 
358
 
        CPPUNIT_ASSERT( entries.find( "xmmy" ) != entries.end() );
359
 
        CPPUNIT_ASSERT( entries.find( "blah" ) == entries.end() );
360
 
        CPPUNIT_ASSERT( entries.find( "bogus" ) == entries.end() );
361
 
 
362
 
        CPPUNIT_ASSERT( entries.find( "one" ) == entries.end() );
363
 
        CPPUNIT_ASSERT( entries.find( "two" ) == entries.end() );
364
 
        CPPUNIT_ASSERT( entries.find( "three" ) == entries.end() );
365
 
        CPPUNIT_ASSERT( entries.find( "four" ) == entries.end() );
366
 
        CPPUNIT_ASSERT( entries.find( "five" ) == entries.end() );
 
342
      // at first the entry list should be empty -- "bogus" known to be empty
 
343
      QStringList entries = QgsProject::instance()->subkeyList( mScope, "/bogus" );
 
344
      cerr << "subkeys: ";
 
345
      for ( QStringList::iterator i = entries.begin();
 
346
            i != entries.end();
 
347
            ++i )
 
348
      {
 
349
        cerr << *i << " ";
 
350
      }
 
351
      cerr << "\n";
 
352
 
 
353
      CPPUNIT_ASSERT( entries.isEmpty() );
 
354
 
 
355
      // So subkeylist for /foo should return only "xmmy".
 
356
 
 
357
      entries = QgsProject::instance()->subkeyList( mScope, "/foo" );
 
358
 
 
359
      cerr << "subkeys: ";
 
360
      for ( QStringList::iterator i = entries.begin();
 
361
            i != entries.end();
 
362
            ++i )
 
363
      {
 
364
        cerr << *i << " ";
 
365
      }
 
366
      cerr << "\n";
 
367
 
 
368
      CPPUNIT_ASSERT( entries.find( "bar" ) == entries.end() );
 
369
      CPPUNIT_ASSERT( entries.find( "baz" ) == entries.end() );
 
370
      CPPUNIT_ASSERT( entries.find( "quux" ) == entries.end() );
 
371
 
 
372
      CPPUNIT_ASSERT( entries.find( "xmmy" ) != entries.end() );
 
373
      CPPUNIT_ASSERT( entries.find( "blah" ) == entries.end() );
 
374
      CPPUNIT_ASSERT( entries.find( "bogus" ) == entries.end() );
 
375
 
 
376
      CPPUNIT_ASSERT( entries.find( "one" ) == entries.end() );
 
377
      CPPUNIT_ASSERT( entries.find( "two" ) == entries.end() );
 
378
      CPPUNIT_ASSERT( entries.find( "three" ) == entries.end() );
 
379
      CPPUNIT_ASSERT( entries.find( "four" ) == entries.end() );
 
380
      CPPUNIT_ASSERT( entries.find( "five" ) == entries.end() );
367
381
    }
368
382
 
369
383
 
370
 
private:
 
384
  private:
371
385
 
372
386
    /// file name for project file
373
387
    QString mFile;