Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/budget/budget-service-mock.js

Issue 2231873002: Added budget_service.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@budget_api
Patch Set: Fixed crash, all tests working Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * Mock implementation of the budget service.
3 */
4
5 "use strict";
6
7 const TEST_BUDGET_COST = 1.2;
8 const TEST_BUDGET_VALUE = 2.3;
johnme 2016/08/17 13:54:01 Nit: value -> available?
harkness 2016/08/18 10:23:26 Done.
9 const TEST_BUDGET_EXPIRATION = 3.4;
johnme 2016/08/17 13:54:01 Whilst 3 milliseconds past midnight 1970 is a vali
harkness 2016/08/18 10:23:26 Done.
10
11 let budgetServiceMock = loadMojoModules(
12 'budgetServiceMock',
13 ['third_party/WebKit/public/platform/modules/budget_service/budget_service.m ojom',
14 'mojo/public/js/router']
15 ).then(mojo => {
johnme 2016/08/17 13:54:01 Nit: please move the ] down next to the )
harkness 2016/08/18 10:23:26 Done.
16 let [budget_service, router] = mojo.modules;
johnme 2016/08/17 13:54:01 Nit: camelCase in JS
harkness 2016/08/18 10:23:26 budget_service is the name of the mojo service, so
johnme 2016/08/18 13:04:31 geolocation-mock.js calls one of its loaded mojo s
harkness 2016/08/22 08:57:47 Sounds good, I'll change it.
17
18 class BudgetServiceMock {
19 constructor(interfaceProvider) {
20 interfaceProvider.addInterfaceOverrideForTesting(
21 budget_service.BudgetService.name,
22 handle => this.connectBudgetService_(handle));
23
24 this.interfaceProvider_ = interfaceProvider;
25 }
26
27 connectBudgetService_(handle) {
28 this.budgetServiceStub_ = new budget_service.BudgetService.stubClass(this) ;
29 this.budgetServiceRouter_ = new router.Router(handle);
30 this.budgetServiceRouter_.setIncomingReceiver(this.budgetServiceStub_);
31 }
32
33 getCost(operationType) {
34 return Promise.resolve({ cost:TEST_BUDGET_COST });
35 }
36
37 getBudget() {
38 return Promise.resolve({ budget: [ { time:TEST_BUDGET_EXPIRATION, budget_a t:TEST_BUDGET_VALUE } ] });
39 }
40 }
41 // Connect to the Mojo interface.
42 return new BudgetServiceMock(mojo.interfaces);
43 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698