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

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: Converted BudgetChunk dictionary to BudgetState interface and other code review updates 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_AT = 2.3;
9 const TEST_BUDGET_TIME = new Date().getTime();
Peter Beverloo 2016/08/22 17:57:55 One thing to consider: Rather than hard coding th
harkness 2016/08/23 09:38:18 I'll make this change in the next CL when I add in
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 => {
16 let [budgetService, router] = mojo.modules;
Peter Beverloo 2016/08/22 17:57:55 nit: s/let/const/
harkness 2016/08/23 09:38:18 Done.
17
18 class BudgetServiceMock {
19 constructor(interfaceProvider) {
20 interfaceProvider.addInterfaceOverrideForTesting(
21 budgetService.BudgetService.name,
22 handle => this.connectBudgetService_(handle));
23
24 this.interfaceProvider_ = interfaceProvider;
25 }
26
27 connectBudgetService_(handle) {
28 this.budgetServiceStub_ = new budgetService.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_TIME, budget_at:TEST _BUDGET_AT } ] });
39 }
40 }
41 // Connect to the Mojo interface.
Peter Beverloo 2016/08/22 17:57:55 nit: drop the comment. This doesn't actually "conn
harkness 2016/08/23 09:38:18 Done.
42 return new BudgetServiceMock(mojo.interfaces);
43 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698