Include chrome_elf pdb in chrome-win32-syms.zip
[chromium-blink-merge.git] / ppapi / tests / test_crypto.cc
blobcfeb5a80bab09fd870b8ff29814ab9009bba29ea
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/tests/test_crypto.h"
7 #include "ppapi/c/dev/ppb_crypto_dev.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/tests/testing_instance.h"
11 REGISTER_TEST_CASE(Crypto);
13 TestCrypto::TestCrypto(TestingInstance* instance)
14 : TestCase(instance),
15 crypto_interface_(NULL) {
18 bool TestCrypto::Init() {
19 crypto_interface_ = static_cast<const PPB_Crypto_Dev*>(
20 pp::Module::Get()->GetBrowserInterface(PPB_CRYPTO_DEV_INTERFACE));
21 return !!crypto_interface_;
24 void TestCrypto::RunTests(const std::string& filter) {
25 RUN_TEST(GetRandomBytes, filter);
28 std::string TestCrypto::TestGetRandomBytes() {
29 const int kBufSize = 16;
30 char buf[kBufSize] = {0};
32 crypto_interface_->GetRandomBytes(buf, kBufSize);
34 // Verify that the interface wrote "something" to the buffer.
35 bool found_nonzero = false;
36 for (int i = 0; i < kBufSize; i++) {
37 if (buf[i]) {
38 found_nonzero = true;
39 break;
42 ASSERT_TRUE(found_nonzero);
44 PASS();