OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/testing_instance.h" | 5 #include "ppapi/tests/testing_instance.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <iomanip> | 9 #include <iomanip> |
10 #include <sstream> | 10 #include <sstream> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ppapi/cpp/core.h" | 13 #include "ppapi/cpp/core.h" |
14 #include "ppapi/cpp/module.h" | 14 #include "ppapi/cpp/module.h" |
15 #include "ppapi/cpp/var.h" | 15 #include "ppapi/cpp/var.h" |
16 #include "ppapi/cpp/var_dictionary.h" | |
16 #include "ppapi/cpp/view.h" | 17 #include "ppapi/cpp/view.h" |
17 #include "ppapi/tests/test_case.h" | 18 #include "ppapi/tests/test_case.h" |
19 #include "ppapi/tests/test_utils.h" | |
18 | 20 |
19 TestCaseFactory* TestCaseFactory::head_ = NULL; | 21 TestCaseFactory* TestCaseFactory::head_ = NULL; |
20 | 22 |
21 // Cookie value we use to signal "we're still working." See the comment above | 23 // Cookie value we use to signal "we're still working." See the comment above |
22 // the class declaration for how this works. | 24 // the class declaration for how this works. |
23 static const char kProgressSignal[] = "..."; | 25 static const char kProgressSignal[] = "..."; |
24 | 26 |
25 // Returns a new heap-allocated test case for the given test, or NULL on | 27 // Returns a new heap-allocated test case for the given test, or NULL on |
26 // failure. | 28 // failure. |
27 TestingInstance::TestingInstance(PP_Instance instance) | 29 TestingInstance::TestingInstance(PP_Instance instance) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 if (current_case_) | 88 if (current_case_) |
87 return current_case_->GetTestObject(); | 89 return current_case_->GetTestObject(); |
88 | 90 |
89 return pp::VarPrivate(); | 91 return pp::VarPrivate(); |
90 } | 92 } |
91 #endif | 93 #endif |
92 | 94 |
93 void TestingInstance::HandleMessage(const pp::Var& message_data) { | 95 void TestingInstance::HandleMessage(const pp::Var& message_data) { |
94 if (current_case_) | 96 if (current_case_) |
95 current_case_->HandleMessage(message_data); | 97 current_case_->HandleMessage(message_data); |
98 | |
99 if (message_data.is_string() && (message_data.AsString() == "isPeripheral")) { | |
100 pp::VarDictionary message; | |
101 message.Set( | |
102 "isPeripheral", | |
103 pp::Var(PP_ToBool(GetTestingInterface()->IsPeripheral(pp_instance())))); | |
104 PostMessage(message); | |
105 } | |
raymes
2015/04/17 01:13:44
It's a bit weird to have this here because this is
tommycli
2015/04/17 23:45:33
Done.
| |
96 } | 106 } |
97 | 107 |
98 void TestingInstance::DidChangeView(const pp::View& view) { | 108 void TestingInstance::DidChangeView(const pp::View& view) { |
99 if (!executed_tests_) { | 109 if (!executed_tests_) { |
100 executed_tests_ = true; | 110 executed_tests_ = true; |
101 pp::Module::Get()->core()->CallOnMainThread( | 111 pp::Module::Get()->core()->CallOnMainThread( |
102 0, | 112 0, |
103 callback_factory_.NewCallback(&TestingInstance::ExecuteTests)); | 113 callback_factory_.NewCallback(&TestingInstance::ExecuteTests)); |
104 } | 114 } |
105 if (current_case_) | 115 if (current_case_) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 } | 332 } |
323 }; | 333 }; |
324 | 334 |
325 namespace pp { | 335 namespace pp { |
326 | 336 |
327 Module* CreateModule() { | 337 Module* CreateModule() { |
328 return new ::Module(); | 338 return new ::Module(); |
329 } | 339 } |
330 | 340 |
331 } // namespace pp | 341 } // namespace pp |
OLD | NEW |