Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 2012 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.
      4 
      5 #ifndef PAPPI_TESTS_TEST_AUDIO_H_
      6 #define PAPPI_TESTS_TEST_AUDIO_H_
      7 
      8 #include <string>
      9 
     10 #include "ppapi/c/ppb_audio.h"
     11 #include "ppapi/c/ppb_audio_config.h"
     12 #include "ppapi/c/ppb_core.h"
     13 #include "ppapi/tests/test_case.h"
     14 
     15 class TestAudio : public TestCase {
     16  public:
     17   explicit TestAudio(TestingInstance* instance);
     18   ~TestAudio();
     19 
     20   // TestCase implementation.
     21   virtual bool Init();
     22   virtual void RunTests(const std::string& filter);
     23 
     24  private:
     25   std::string TestCreation();
     26   std::string TestDestroyNoStop();
     27   std::string TestFailures();
     28   std::string TestAudioCallback1();
     29   std::string TestAudioCallback2();
     30   std::string TestAudioCallback3();
     31 
     32   // Calls |audio_callback_method_| (where |user_data| is "this").
     33   static void AudioCallbackTrampoline(void* sample_buffer,
     34                                       uint32_t buffer_size_in_bytes,
     35                                       void* user_data);
     36 
     37   typedef void (TestAudio::*AudioCallbackMethod)(void* sample_buffer,
     38                                                  uint32_t buffer_size_in_bytes);
     39 
     40   // Method called by |AudioCallbackTrampoline()|. Set only when the callback
     41   // can't be running (before |StartPlayback()|, after |StopPlayback()| or
     42   // releasing the last reference to the audio resource).
     43   AudioCallbackMethod audio_callback_method_;
     44 
     45   // An |AudioCallbackMethod| that just clears |sample_buffer|.
     46   void AudioCallbackTrivial(void* sample_buffer, uint32_t buffer_size_in_bytes);
     47 
     48   // |AudioCallbackMethod| used by |TestAudioCallbackN()|.
     49   void AudioCallbackTest(void* sample_buffer, uint32_t buffer_size_in_bytes);
     50 
     51   // Used by |TestAudioCallbackN()|.
     52   NestedEvent audio_callback_event_;
     53 
     54   bool test_done_;
     55   bool callback_fired_;
     56 
     57   // Raw C-level interfaces, set in |Init()|; do not modify them elsewhere.
     58   const PPB_Audio* audio_interface_;
     59   const PPB_AudioConfig* audio_config_interface_;
     60   const PPB_Core* core_interface_;
     61 };
     62 
     63 #endif  // PAPPI_TESTS_TEST_AUDIO_H_
     64