root/trunk/tests/PreferencesPterTest.cxx

Revision 198, 2.1 kB (checked in by jordi, 2 years ago)

Added the PreferencesPter? and IPreferencesView classes as well as they test suite PreferencesPterTest? and DumbPreferencesView? classes. The first test, that tests that setting the browser command line changes the configuration, works.

Line 
1// ePDFView - Preferences Presenter Test Fixture.
2// Copyright (C) 2006 Emma's Software.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18#include <epdfview.h>
19#include "DumbPreferencesView.h"
20#include "PreferencesPterTest.h"
21
22using namespace ePDFView;
23
24// Register the test suite into the `registry'.
25CPPUNIT_TEST_SUITE_REGISTRATION (PreferencesPterTest);
26
27///
28/// @brief Sets up the environment for each test.
29///
30void
31PreferencesPterTest::setUp ()
32{
33    Config::loadFile (FALSE);
34    m_PreferencesPter = new PreferencesPter ();
35    m_View = new DumbPreferencesView ();
36    m_PreferencesPter->setView (m_View);
37}
38
39///
40/// @brief Cleans up after each test.
41///
42void
43PreferencesPterTest::tearDown ()
44{
45    Config::destroy ();
46    // Telling the presenter to close will delete the view and the presenter.
47    m_PreferencesPter->closeActivated ();
48    m_PreferencesPter = NULL;
49    m_View = NULL;
50}
51
52///
53/// @brief Test setting the external browser command line.
54///
55void
56PreferencesPterTest::externalCommandBrowser ()
57{
58    Config &config = Config::getConfig ();
59
60    gchar *commandLine = config.getExternalBrowserCommandLine ();
61    CPPUNIT_ASSERT ( 0 == g_ascii_strcasecmp ("firefox %s", commandLine));
62    g_free (commandLine);
63
64    m_View->setBrowserCommandLine ("Eterm links %s");
65    m_PreferencesPter->browserCommandLineChanged ();
66
67    commandLine = config.getExternalBrowserCommandLine ();
68    CPPUNIT_ASSERT ( 0 == g_ascii_strcasecmp ("Eterm links %s", commandLine));
69    g_free (commandLine);
70}
Note: See TracBrowser for help on using the browser.