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

Side by Side Diff: media/cdm/ppapi/cdm_file_io_test.cc

Issue 93243003: Add CDM FileIO tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
ddorwin 2013/12/04 05:27:08 Ideally, we'd have more tests that close the file,
xhwang 2013/12/10 01:24:25 Yes, that's in the plan. Added TODO.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/cdm/ppapi/cdm_file_io_test.h"
6
7 #include "base/callback_helpers.h"
8 #include "media/base/bind_to_loop.h"
9
10 namespace media {
11
12 #define RETURN_ON_FAILURE(status, log) \
13 do { \
14 if ((status) != kSuccess) { \
15 LOG(ERROR) << log; \
ddorwin 2013/12/04 05:27:08 Since this comes from a CDM, we should probably ad
xhwang 2013/12/10 01:24:25 Done.
16 OnTestComplete(false); \
17 return; \
18 } \
19 } while (0)
20
21 const char kTestFileName[] = "cdm_file_io_test_file";
22 const uint8_t kTestData[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
ddorwin 2013/12/04 05:27:08 We need really big test data to test the multiple
xhwang 2013/12/10 01:24:25 Added TODO.
23 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
24
25 CdmFileIOTest::CdmFileIOTest()
26 : cdm_file_io_(NULL),
27 test_data_(kTestData, kTestData + arraysize(kTestData)) {}
28
29 CdmFileIOTest::~CdmFileIOTest() {}
30
31 void CdmFileIOTest::OnOpenComplete(Status status) {
32 LOG(ERROR) << __FUNCTION__;
ddorwin 2013/12/04 05:27:08 debugging leftovers?
xhwang 2013/12/10 01:24:25 Removed.
33 RETURN_ON_FAILURE(status, "Open failed.");
34
35 cdm_file_io_->Write(&test_data_[0], test_data_.size());
36 }
37
38 void CdmFileIOTest::OnReadComplete(Status status,
39 const uint8_t* data, uint32_t data_size) {
40 LOG(ERROR) << __FUNCTION__;
41 RETURN_ON_FAILURE(status, "Read failed.");
42
43 std::vector<uint8_t> data_read(data, data + data_size);
44 bool success = (test_data_ == data_read);
45 OnTestComplete(success);
ddorwin 2013/12/04 05:27:08 Here we don't get details about what failed. Shoul
xhwang 2013/12/10 01:24:25 Done.
46 }
47
48 void CdmFileIOTest::OnWriteComplete(Status status) {
49 LOG(ERROR) << __FUNCTION__;
50 RETURN_ON_FAILURE(status, "Write failed.");
51
52 cdm_file_io_->Read();
53 }
54
55 void CdmFileIOTest::Run(cdm::CdmFileIO* cdm_file_io,
56 CompletionCB completion_cb) {
57 LOG(ERROR) << __FUNCTION__;
58
59 cdm_file_io_ = cdm_file_io;
60 completion_cb_ = BindToCurrentLoop(completion_cb);
61
62 cdm_file_io_->Open(kTestFileName, arraysize(kTestFileName));
63 }
64
65 void CdmFileIOTest::OnTestComplete(bool success) {
66 base::ResetAndReturn(&completion_cb_).Run(success);
67 cdm_file_io_->Close();
68 cdm_file_io_ = NULL;
69 }
70
71 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698