Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for offline data with an online license request #878

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions test/offline/offline_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,45 @@ describe('Offline', function() {
.catch(fail)
.then(done);
});

it('stores, plays, and deletes protected content with a temporary license', function(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change these it() calls to drm_it(). We only run DRM tests with the --drm flag, and drm_it() does the filtering for us.

We do it this way so that tests can still be run without solid network connectivity. --drm enables DRM tests (some networking required for licensing) and --external enables external asset tests (solid network required to pull content from the internet).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

if (!support['offline']) {
pending('Offline storage not supported');
}

shaka.test.TestScheme.setupPlayer(player, 'sintel-enc');
var onError = function(e) {
// We should only get a not-found error.
var expected = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,
shaka.util.Error.Code.OFFLINE_SESSION_REMOVED);
shaka.test.Util.expectToEqualError(e, expected);
};

var storedContent;
var drmEngine;
storage.configure({ isPersistentLicense: false });
storage.store('test:sintel-enc')
.then(function(content) {
storedContent = content;
expect(storedContent.offlineUri).toBe('offline:0');
return player.load(storedContent.offlineUri);
})
.then(function() {
video.play();
return shaka.test.Util.delay(5);
})
.then(function() { return dbEngine.get('manifest', 0); })
.then(function(manifestDb) {
expect(manifestDb.sessionIds.length).toEqual(0);

expect(video.currentTime).toBeGreaterThan(3);
expect(video.ended).toBe(false);
return player.unload();
})
.then(function() { return storage.remove(storedContent); })
.catch(fail)
.then(done);
})
});
55 changes: 55 additions & 0 deletions test/offline/storage_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,43 @@ describe('Storage', function() {
}).catch(fail).then(done);
});
}); // describe('default track selection callback')

describe('temporary license', function(){

beforeEach(function(){
storage.configure({ isPersistentLicense: false });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't configure DRM, so the tests below are all exercising clear content paths. See the drmEngine setup in the 'stores DRM info' test and do the same here in beforeEach.

});

it('stores basic manifests', function(done) {
var originalUri = 'fake://foobar';
storage.store(originalUri)
.then(function(data) {
expect(data).toBeTruthy();
// Since we are using a memory DB, it will always be the first one.
expect(data.offlineUri).toBe('offline:0');
expect(data.originalManifestUri).toBe(originalUri);
expect(data.duration).toBe(0); // There are no segments.
expect(data.size).toEqual(0);
expect(data.tracks).toEqual(tracks);
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also load the content again and verify that is has drmInfo (see below) so that you know you aren't just testing clear content.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a new 'stores drm info' test (along with the additions to beforeEach) to check the drmInfo.

Is this what you meant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of. I was thinking of putting checks for drmInfo into the offline sessions test below. Otherwise, running that test in isolation could result in a pass even if it was clear content.

Since the feature under test is that we do temporary licenses instead of persistent licenses, I think all three of these could be one test. In my opinion, the test above ("stores basic manifest") is irrelevant, and these other two should be combined into "does not store offline sessions").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense. As this creates a describe with a single it in it, would you like that to be flattened into a standalone it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped down to the single test inside the describe group.

.catch(fail)
.then(done);
});

it('does not store offline sessions', function(done) {
storage.store('')
.then(function(data) {
expect(data.offlineUri).toBe('offline:0');
return fakeStorageEngine.get('manifest', 0);
})
.then(function(manifestDb) {
expect(manifestDb).toBeTruthy();
expect(manifestDb.sessionIds.length).toEqual(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also verify that manifestDb.drmInfo exists and matches the one you create in beforeEach, or else this is passing for the wrong reasons (clear content).

})
.catch(fail)
.then(done);
});
}); // describe('temporary license')
}); // describe('store')

describe('remove', function() {
Expand Down Expand Up @@ -963,6 +1000,24 @@ describe('Storage', function() {
.then(done);
});

it('will delete content with a temporary license', function(done){
storage.configure({ isPersistentLicense: false });
var manifestId = 0;
createAndInsertSegments(manifestId, 5)
.then(function(refs) {
var manifest = createManifest(manifestId);
manifest.periods[0].streams.push({segments: refs});
return fakeStorageEngine.insert('manifest', manifest);
})
.then(function() {
expectDatabaseCount(1, 5);
return removeManifest(manifestId);
})
.then(function() { expectDatabaseCount(0, 0); })
.catch(fail)
.then(done);
});

it('will not delete other manifest\'s segments', function(done) {
var manifestId1 = 1;
var manifestId2 = 2;
Expand Down