| Index: content/shell/renderer/test_runner/mock_web_midi_accessor.cc
|
| diff --git a/content/shell/renderer/test_runner/mock_web_midi_accessor.cc b/content/shell/renderer/test_runner/mock_web_midi_accessor.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dc9d45841c912b68c1bba9372ed07f8e8879ee0d
|
| --- /dev/null
|
| +++ b/content/shell/renderer/test_runner/mock_web_midi_accessor.cc
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/shell/renderer/test_runner/mock_web_midi_accessor.h"
|
| +
|
| +#include "content/shell/renderer/test_runner/TestInterfaces.h"
|
| +#include "content/shell/renderer/test_runner/WebTestDelegate.h"
|
| +#include "content/shell/renderer/test_runner/test_runner.h"
|
| +#include "content/shell/renderer/test_runner/web_test_runner.h"
|
| +#include "third_party/WebKit/public/platform/WebMIDIAccessorClient.h"
|
| +
|
| +namespace content {
|
| +
|
| +namespace {
|
| +
|
| +class DidStartSessionTask : public WebMethodTask<MockWebMIDIAccessor> {
|
| + public:
|
| + DidStartSessionTask(MockWebMIDIAccessor* object,
|
| + blink::WebMIDIAccessorClient* client,
|
| + bool result)
|
| + : WebMethodTask<MockWebMIDIAccessor>(object),
|
| + client_(client),
|
| + result_(result) {}
|
| +
|
| + virtual void runIfValid() OVERRIDE {
|
| + client_->didStartSession(result_, "InvalidStateError", "");
|
| + }
|
| +
|
| + private:
|
| + blink::WebMIDIAccessorClient* client_;
|
| + bool result_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DidStartSessionTask);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client,
|
| + TestInterfaces* interfaces)
|
| + : client_(client), interfaces_(interfaces) {
|
| +}
|
| +
|
| +MockWebMIDIAccessor::~MockWebMIDIAccessor() {
|
| +}
|
| +
|
| +void MockWebMIDIAccessor::startSession() {
|
| + // Add a mock input and output port.
|
| + client_->didAddInputPort("MockInputID",
|
| + "MockInputManufacturer",
|
| + "MockInputName",
|
| + "MockInputVersion");
|
| + client_->didAddOutputPort("MockOutputID",
|
| + "MockOutputManufacturer",
|
| + "MockOutputName",
|
| + "MockOutputVersion");
|
| + interfaces_->delegate()->postTask(new DidStartSessionTask(
|
| + this, client_, interfaces_->testRunner()->midiAccessorResult()));
|
| +}
|
| +
|
| +} // namespace content
|
|
|