forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boca: Implement client delegate for update session.
Also include a few fixes: 1. Add in session Id and teacher as they're required for every session update request. 2. Only allow update active session. 3. Remove the hardcoded duration. Test: unit tested. Bug: b:368071298 Change-Id: Ia1b8b6a288e596a60692456bc6e99a6adc0621cc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5879481 Reviewed-by: Benjamin Zielinski <[email protected]> Commit-Queue: April Zhou <[email protected]> Cr-Commit-Position: refs/heads/main@{#1358507}
- Loading branch information
Showing
7 changed files
with
208 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// found in the LICENSE file. | ||
|
||
import {ClientDelegateFactory} from 'chrome-untrusted://boca-app/app/client_delegate.js'; | ||
import {Config, Course, Identity, PageHandlerRemote, SessionResult, Window} from 'chrome-untrusted://boca-app/mojom/boca.mojom-webui.js'; | ||
import {CaptionConfig, Config, Course, Identity, OnTaskConfig, PageHandlerRemote, SessionResult, UpdateSessionError, Window} from 'chrome-untrusted://boca-app/mojom/boca.mojom-webui.js'; | ||
import {Url} from 'chrome-untrusted://resources/mojo/url/mojom/url.mojom-webui.js'; | ||
import {assertDeepEquals, assertTrue} from 'chrome-untrusted://webui-test/chai_assert.js'; | ||
|
||
|
@@ -48,8 +48,7 @@ class MockRemoteHandler extends PageHandlerRemote { | |
{ | ||
sessionDuration: { | ||
// BigInt serialized as string. | ||
// TODO(b/365141108) Fix this after we remove hard-coded duration. | ||
microseconds: 120000000n, | ||
microseconds: 7200000000n, | ||
}, | ||
students: [ | ||
{id: '1', name: 'cat', email: '[email protected]'}, | ||
|
@@ -128,6 +127,50 @@ class MockRemoteHandler extends PageHandlerRemote { | |
}, | ||
}); | ||
} | ||
|
||
override updateOnTaskConfig(config: OnTaskConfig): | ||
Promise<{error: UpdateSessionError | null}> { | ||
assertDeepEquals( | ||
{ | ||
isLocked: true, | ||
tabs: [ | ||
{ | ||
tab: { | ||
url: {url: 'http://google.com/'}, | ||
title: 'google', | ||
favicon: 'data/image', | ||
}, | ||
navigationType: 0, | ||
}, | ||
{ | ||
tab: { | ||
url: {url: 'http://youtube.com/'}, | ||
title: 'youtube', | ||
favicon: 'data/image', | ||
}, | ||
navigationType: 1, | ||
}, | ||
], | ||
}, | ||
config); | ||
return Promise.resolve({error: null}); | ||
} | ||
|
||
override updateCaptionConfig(config: CaptionConfig): | ||
Promise<{error: UpdateSessionError | null}> { | ||
assertDeepEquals( | ||
{ | ||
captionEnabled: true, | ||
transcriptionEnabled: true, | ||
local: true, | ||
}, | ||
config); | ||
return Promise.resolve({error: null}); | ||
} | ||
|
||
override endSession(): Promise<{error: UpdateSessionError | null}> { | ||
return Promise.resolve({error: null}); | ||
} | ||
} | ||
|
||
suite('ClientDelegateTest', function() { | ||
|
@@ -274,4 +317,46 @@ suite('ClientDelegateTest', function() { | |
result); | ||
}); | ||
|
||
test( | ||
'client delegate should translate data for update on task config', | ||
async () => { | ||
const result = | ||
await clientDelegateImpl.getInstance().updateOnTaskConfig({ | ||
isLocked: true, | ||
tabs: [ | ||
{ | ||
tab: { | ||
title: 'google', | ||
url: 'http://google.com/', | ||
favicon: 'data/image', | ||
}, | ||
navigationType: 0, | ||
}, | ||
{ | ||
tab: { | ||
title: 'youtube', | ||
url: 'http://youtube.com/', | ||
favicon: 'data/image', | ||
}, | ||
navigationType: 1, | ||
}, | ||
], | ||
}); | ||
assertTrue(result); | ||
}); | ||
|
||
test('client delegate should translate data for caption config', async () => { | ||
const result = await clientDelegateImpl.getInstance().updateCaptionConfig({ | ||
captionEnabled: true, | ||
local: true, | ||
transcriptionEnabled: true, | ||
}); | ||
assertTrue(result); | ||
}); | ||
|
||
test('client delegate should translate data for end session', async () => { | ||
const result = await clientDelegateImpl.getInstance().endSession(); | ||
assertTrue(result); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters