aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llassetuploadqueue_tut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/test/llassetuploadqueue_tut.cpp')
-rw-r--r--linden/indra/test/llassetuploadqueue_tut.cpp200
1 files changed, 200 insertions, 0 deletions
diff --git a/linden/indra/test/llassetuploadqueue_tut.cpp b/linden/indra/test/llassetuploadqueue_tut.cpp
new file mode 100644
index 0000000..13c8fea
--- /dev/null
+++ b/linden/indra/test/llassetuploadqueue_tut.cpp
@@ -0,0 +1,200 @@
1/**
2 * @file asset_upload_queue_tut.cpp
3 * @brief Tests for newview/llassetuploadqueue.cpp
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33#include "lltut.h"
34
35#include "mock_http_client.h"
36#include "../newview/llassetuploadqueue.cpp"
37
38// Mock implementation.
39LLAssetUploadResponder::LLAssetUploadResponder(const LLSD& post_data,
40 const LLUUID& vfile_id,
41 LLAssetType::EType asset_type)
42{
43}
44
45LLAssetUploadResponder::LLAssetUploadResponder(const LLSD& post_data, const std::string& file_name)
46{
47}
48
49LLAssetUploadResponder::~LLAssetUploadResponder()
50{
51}
52
53void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason)
54{
55}
56
57void LLAssetUploadResponder::result(const LLSD& content)
58{
59}
60
61void LLAssetUploadResponder::uploadUpload(const LLSD& content)
62{
63}
64
65void LLAssetUploadResponder::uploadComplete(const LLSD& content)
66{
67}
68
69void LLAssetUploadResponder::uploadFailure(const LLSD& content)
70{
71}
72
73LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
74 const LLUUID& vfile_id,
75 LLAssetType::EType asset_type) :
76 LLAssetUploadResponder(post_data, vfile_id, asset_type)
77{
78}
79
80LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
81 const std::string& file_name) :
82 LLAssetUploadResponder(post_data, file_name)
83{
84}
85
86LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
87 const std::string& file_name,
88 const LLUUID& queue_id) :
89 LLAssetUploadResponder(post_data, file_name)
90{
91}
92
93void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
94{
95}
96
97namespace tut
98{
99 class asset_upload_queue_test_data : public MockHttpClient {};
100 typedef test_group<asset_upload_queue_test_data> asset_upload_queue_test;
101 typedef asset_upload_queue_test::object asset_upload_queue_object;
102 tut::asset_upload_queue_test asset_upload_queue("asset_upload_queue");
103
104 void queue(LLAssetUploadQueue& q, const std::string& filename)
105 {
106 LLUUID task_id;
107 LLUUID item_id;
108 BOOL is_running = FALSE;
109 BOOL is_target_mono = TRUE;
110 LLUUID queue_id;
111 q.queue(filename, task_id, item_id, is_running, is_target_mono, queue_id);
112 }
113
114 class LLTestSupplier : public LLAssetUploadQueueSupplier
115 {
116 public:
117
118 void set(LLAssetUploadQueue* queue) {mQueue = queue;}
119
120 virtual LLAssetUploadQueue* get() const
121 {
122 return mQueue;
123 }
124
125 private:
126 LLAssetUploadQueue* mQueue;
127 };
128
129 template<> template<>
130 void asset_upload_queue_object::test<1>()
131 {
132 setupTheServer();
133 reset();
134 LLTestSupplier* supplier = new LLTestSupplier();
135 LLAssetUploadQueue q("http://localhost:8888/test/success", supplier);
136 supplier->set(&q);
137 queue(q, "foo.bar");
138 ensure("upload queue not empty before request", q.isEmpty());
139 runThePump(10);
140 ensure("upload queue not empty after request", q.isEmpty());
141 }
142
143 template<> template<>
144 void asset_upload_queue_object::test<2>()
145 {
146 reset();
147 LLTestSupplier* supplier = new LLTestSupplier();
148 LLAssetUploadQueue q("http://localhost:8888/test/error", supplier);
149 supplier->set(&q);
150 queue(q, "foo.bar");
151 ensure("upload queue not empty before request", q.isEmpty());
152 runThePump(10);
153 ensure("upload queue not empty after request", q.isEmpty());
154 }
155
156 template<> template<>
157 void asset_upload_queue_object::test<3>()
158 {
159 reset();
160 LLTestSupplier* supplier = new LLTestSupplier();
161 LLAssetUploadQueue q("http://localhost:8888/test/timeout", supplier);
162 supplier->set(&q);
163 queue(q, "foo.bar");
164 ensure("upload queue not empty before request", q.isEmpty());
165 runThePump(10);
166 ensure("upload queue not empty after request", q.isEmpty());
167 }
168
169 template<> template<>
170 void asset_upload_queue_object::test<4>()
171 {
172 reset();
173 LLTestSupplier* supplier = new LLTestSupplier();
174 LLAssetUploadQueue q("http://localhost:8888/test/success", supplier);
175 supplier->set(&q);
176 queue(q, "foo.bar");
177 queue(q, "baz.bar");
178 ensure("upload queue empty before request", !q.isEmpty());
179 runThePump(10);
180 ensure("upload queue not empty before request", q.isEmpty());
181 runThePump(10);
182 ensure("upload queue not empty after request", q.isEmpty());
183 }
184
185 template<> template<>
186 void asset_upload_queue_object::test<5>()
187 {
188 reset();
189 LLTestSupplier* supplier = new LLTestSupplier();
190 LLAssetUploadQueue q("http://localhost:8888/test/success", supplier);
191 supplier->set(&q);
192 queue(q, "foo.bar");
193 runThePump(10);
194 ensure("upload queue not empty before request", q.isEmpty());
195 queue(q, "baz.bar");
196 ensure("upload queue not empty after request", q.isEmpty());
197 runThePump(10);
198 killServer();
199 }
200}