PageRenderTime 232ms CodeModel.GetById 19ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/viewer_components/updater/tests/llupdaterservice_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 194 lines | 129 code | 19 blank | 46 comment | 0 complexity | 92999fdcf82ef45b7f0b561b59fe80f5 MD5 | raw file
  1/**
  2 * @file   llupdaterservice_test.cpp
  3 * @brief  Tests of llupdaterservice.cpp.
  4 * 
  5 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27// Precompiled header
 28#include "linden_common.h"
 29// associated header
 30#include "../llupdaterservice.h"
 31#include "../llupdatechecker.h"
 32#include "../llupdatedownloader.h"
 33#include "../llupdateinstaller.h"
 34
 35#include "../../../test/lltut.h"
 36//#define DEBUG_ON
 37#include "../../../test/debug.h"
 38
 39#include "llevents.h"
 40#include "lldir.h"
 41
 42/*****************************************************************************
 43*   MOCK'd
 44*****************************************************************************/
 45LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client)
 46{}
 47void LLUpdateChecker::check(std::string const & protocolVersion, std::string const & hostUrl, 
 48								  std::string const & servicePath, std::string channel, std::string version)
 49{}
 50LLUpdateDownloader::LLUpdateDownloader(Client & ) {}
 51void LLUpdateDownloader::download(LLURI const & , std::string const &, std::string const &, bool){}
 52
 53class LLDir_Mock : public LLDir
 54{
 55	void initAppDirs(const std::string &app_name, 
 56		   			 const std::string& app_read_only_data_dir = "") {}
 57	U32 countFilesInDir(const std::string &dirname, const std::string &mask) 
 58	{
 59		return 0;
 60	}
 61
 62	void getRandomFileInDir(const std::string &dirname, 
 63							const std::string &mask, 
 64							std::string &fname) {}
 65	std::string getCurPath() { return ""; }
 66	BOOL fileExists(const std::string &filename) const { return false; }
 67	std::string getLLPluginLauncher() { return ""; }
 68	std::string getLLPluginFilename(std::string base_name) { return ""; }
 69
 70} gDirUtil;
 71LLDir* gDirUtilp = &gDirUtil;
 72LLDir::LLDir() {}
 73LLDir::~LLDir() {}
 74S32 LLDir::deleteFilesInDir(const std::string &dirname, 
 75							const std::string &mask)
 76{ return 0; }
 77
 78void LLDir::setChatLogsDir(const std::string &path){}		
 79void LLDir::setPerAccountChatLogsDir(const std::string &username){}
 80void LLDir::setLindenUserDir(const std::string &username){}		
 81void LLDir::setSkinFolder(const std::string &skin_folder){}
 82bool LLDir::setCacheDir(const std::string &path){ return true; }
 83void LLDir::dumpCurrentDirectories() {}
 84
 85std::string LLDir::getExpandedFilename(ELLPath location, 
 86									   const std::string &filename) const 
 87{
 88	return "";
 89}
 90
 91std::string LLUpdateDownloader::downloadMarkerPath(void)
 92{
 93	return "";
 94}
 95
 96void LLUpdateDownloader::resume(void) {}
 97void LLUpdateDownloader::cancel(void) {}
 98void LLUpdateDownloader::setBandwidthLimit(U64 bytesPerSecond) {}
 99
100int ll_install_update(std::string const &, std::string const &, bool, LLInstallScriptMode)
101{
102	return 0;
103}
104
105std::string const & ll_install_failed_marker_path()
106{
107	static std::string wubba;
108	return wubba;
109}
110
111/*
112#pragma warning(disable: 4273)
113llus_mock_llifstream::llus_mock_llifstream(const std::string& _Filename,
114										   ios_base::openmode _Mode,
115										   int _Prot) :
116	std::basic_istream<char,std::char_traits< char > >(NULL,true)
117{}
118
119llus_mock_llifstream::~llus_mock_llifstream() {}
120bool llus_mock_llifstream::is_open() const {return true;}
121void llus_mock_llifstream::close() {}
122*/
123
124/*****************************************************************************
125*   TUT
126*****************************************************************************/
127namespace tut
128{
129    struct llupdaterservice_data
130    {
131		llupdaterservice_data() :
132            pumps(LLEventPumps::instance()),
133			test_url("dummy_url"),
134			test_channel("dummy_channel"),
135			test_version("dummy_version")
136		{}
137		LLEventPumps& pumps;
138		std::string test_url;
139		std::string test_channel;
140		std::string test_version;
141	};
142
143    typedef test_group<llupdaterservice_data> llupdaterservice_group;
144    typedef llupdaterservice_group::object llupdaterservice_object;
145    llupdaterservice_group llupdaterservicegrp("LLUpdaterService");
146
147    template<> template<>
148    void llupdaterservice_object::test<1>()
149    {
150        DEBUG;
151		LLUpdaterService updater;
152		bool got_usage_error = false;
153		try
154		{
155			updater.startChecking();
156		}
157		catch(LLUpdaterService::UsageError)
158		{
159			got_usage_error = true;
160		}
161		ensure("Caught start before params", got_usage_error);
162	}
163
164    template<> template<>
165    void llupdaterservice_object::test<2>()
166    {
167        DEBUG;
168		LLUpdaterService updater;
169		bool got_usage_error = false;
170		try
171		{
172			updater.initialize("1.0",test_url, "update" ,test_channel, test_version);
173			updater.startChecking();
174			updater.initialize("1.0", "other_url", "update", test_channel, test_version);
175		}
176		catch(LLUpdaterService::UsageError)
177		{
178			got_usage_error = true;
179		}
180		ensure("Caught params while running", got_usage_error);
181	}
182
183    template<> template<>
184    void llupdaterservice_object::test<3>()
185    {
186        DEBUG;
187		LLUpdaterService updater;
188		updater.initialize("1.0", test_url, "update", test_channel, test_version);
189		updater.startChecking();
190		ensure(updater.isChecking());
191		updater.stopChecking();
192		ensure(!updater.isChecking());
193	}
194}