What's new? | Help | Directory | Sign in
Google
gears
Improving Your Web Browser
  
  
  
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Copyright 2008, Google Inc.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifdef USING_CCTESTS

#ifndef GEARS_CCTESTS_TEST_H__
#define GEARS_CCTESTS_TEST_H__

#ifdef WINCE
#include <windows.h>
#include <wininet.h> // For INTERNET_CACHE_ENTRY_INFO
#endif
#include "gears/base/common/base_class.h"
#include "gears/base/common/common.h"
#include "gears/geolocation/geolocation.h"

class GearsTest : public ModuleImplBaseClass {
public:
GearsTest()
: ModuleImplBaseClass("GearsTest"),
start_ticks_(0) {}

// IN: nothing
// OUT: int64 time
void GetSystemTime(JsCallContext *context);

// IN: nothing
// OUT: nothing
void StartPerfTimer(JsCallContext *context);

// IN: nothing
// OUT: int64 elapsed_microseconds
void StopPerfTimer(JsCallContext *context);

// IN: bool is_worker
// OUT: nothing
void RunTests(JsCallContext *context);


// JsObject and JsArray tests

// IN: object value
// OUT: void
// throws exception on failure
void TestPassObject(JsCallContext *context);

// IN: function test_function
// OUT: object created_object
// throws exception on failure
void TestCreateObject(JsCallContext *context);

// IN: void
// OUT: object created_object
// throws exception on failure
void TestCreateError(JsCallContext *context);

// IN: nothing
// OUT: nothing
// throws exception on failure
void TestObjectProperties(JsCallContext *context);

// Argument passing tests

// IN: bool bool_value, int int_value, int64 int64_value, double double_value,
// string string_value
// OUT: void
void TestPassArguments(JsCallContext *context);

// IN: function
// OUT: bool bool_value, int int_value, int64 int64_value,
// double double_value, string string_value
void TestPassArgumentsCallback(JsCallContext *context);

// IN: int value1, optional int value2, optional int value3
// OUT: void
void TestPassArgumentsOptional(JsCallContext *context);

// Coercion tests

// IN: variant value, bool expected_value
// OUT: bool
void TestCoerceBool(JsCallContext *context);
// IN: variant value, int expected_value
// OUT: bool
void TestCoerceInt(JsCallContext *context);
// IN: variant value, double expected_value
// OUT: bool
void TestCoerceDouble(JsCallContext *context);
// IN: variant value, string expected_value
// OUT: bool
void TestCoerceString(JsCallContext *context);
// IN: string type, variant value
// OUT: bool
void TestGetType(JsCallContext *context);

#ifdef WINCE
// These methods are used by the JavaScript testBrowserCache test.

// IN: variant urls
// OUT: bool
void RemoveEntriesFromBrowserCache(JsCallContext *context);
// IN: variant urls, bool should_be_present, bool should_be_bogus
// OUT: bool
void TestEntriesPresentInBrowserCache(JsCallContext *context);
#endif

// Geolocation internal tests.

// IN: object position_options
// OUT: object parsed_options
void TestParseGeolocationOptions(JsCallContext *context);

// IN: nothing
// OUT: string request_body
void TestGeolocationFormRequestBody(JsCallContext *context);

// IN: string response_body
// OUT: object position
void TestGeolocationGetLocationFromResponse(JsCallContext *context);

// Configures the radio data provider factory to use a mock radio device data
// provider and sets the cell data that the mock provider will provide.
// IN: object cell_data (Fields are cell_id, location_area_code,
// mobile_network_code, mobile_country_code, age and timing_advance, all
// as integers.)
// OUT: nothing
void ConfigureGeolocationRadioDataProviderForTest(JsCallContext *context);

// Configures the wifi data provider factory to use a mock wifi device data
// provider.
// TODO(baran): Enable passing a wifi data object as a JavaScript object, so
// that callers can specify the wifi data.
// IN: nothing
// OUT: nothing
void ConfigureGeolocationWifiDataProviderForTest(JsCallContext *context);

#ifdef OFFICIAL_BUILD
// The Audio API has not been finalized for official builds.
#else
// Audio internal tests.

// Sets the (audio recorder) device factories to use mock device.
// IN: nothing
// OUT: nothing
void ConfigureAudioRecorderForTest(JsCallContext *context);
#endif

// IN: string input
// OUT: GearsBlob
// The resultant Blob's contents will the input string in UTF-8 format.
void CreateBlobFromString(JsCallContext *context);

// IN: optional int numOrigs
// optional int numStoresPerOrigin
// optional int numItemsPerStore
// OUT: string, timing results
void TestLocalServerPerformance(JsCallContext *context);

#ifdef OFFICIAL_BUILD
// The Notification API has not been finalized for official builds.
#else
// Notification internal tests.

// IN: nothing
// OUT: nothing
void TestNotifier(JsCallContext *context);
#endif // OFFICIAL_BUILD

private:
// The tick count used by the perf timer.
int64 start_ticks_;

DISALLOW_EVIL_CONSTRUCTORS(GearsTest);
};

#ifdef WINCE
// These functions are declared in wince_compatibility.cc. They are wrappers
// around static functions defined there.
INTERNET_CACHE_ENTRY_INFO* GetEntryInfoTest(const char16 *url);
bool IsEntryBogusTest(INTERNET_CACHE_ENTRY_INFO *info);
#endif

#endif // GEARS_CCTESTS_TEST_H__

#endif // USING_CCTESTS
Show details Hide details

Change log

r2471 by gears.daemon on Yesterday (30 hours ago)   Diff
[Author: steveblock]

Refactors perf timer on test object to
avoid the need to pass very large tick
counts to JavaScript.

The perf timer was added to allow high
precision timing, because
GetCurrenttimeMillis() has poor precision
on some platforms. The perf timer was also
exposed directly to JavaScript through the
test object.
...
Go to: 
Project members, sign in to write a code review

Older revisions

r2461 by gears.daemon on Yesterday (45 hours ago)   Diff
[Author: nigeltao]

Eliminate ModuleImplBaseClassVirtual,
since all Modules are
now Dispatcher-backed, on Firefox.
...
r2448 by gears.daemon on Jul 22 (2 days ago)   Diff
[Author: steveblock]

Updates getSystemTime, getTimingTicks
and getTimingTickDeltaMicros to return
integers.
...
r2433 by gears.daemon on Jul 21 (3 days ago)   Diff
[Author: steveblock]

Prepares Geolocation API for the big
time.

...
All revisions of this file

File info

Size: 6740 bytes, 207 lines