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

Side by Side Diff: ppapi/tests/power_saver_test_plugin.cc

Issue 1088763002: Plugin Power Saver: Add comprehensive browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0260-plugins-overhaul-prerender-tests
Patch Set: update isolate Created 5 years, 8 months 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #include <algorithm>
6
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/var.h"
10 #include "ppapi/cpp/var_dictionary.h"
11 #include "ppapi/tests/test_utils.h"
12
13 // When compiling natively on Windows, PostMessage can be #define-d to
14 // something else.
15 #ifdef PostMessage
16 #undef PostMessage
17 #endif
18
19 // This is a simple C++ Pepper plugin that enables Plugin Power Saver tests.
20 class PowerSaverTestInstance : public pp::Instance {
21 public:
22 explicit PowerSaverTestInstance(PP_Instance instance)
23 : pp::Instance(instance) {}
24 virtual ~PowerSaverTestInstance() {}
25 virtual void HandleMessage(const pp::Var& message_data);
26 };
27
28 // When postMessage("isPeripheral") is called on the DOM element associated
29 // with this plugin instance, we respond with a Javascript object containing
30 // a boolean indicating if the plugin has been marked peripheral.
31 void PowerSaverTestInstance::HandleMessage(const pp::Var& message_data) {
32 if (message_data.is_string() && (message_data.AsString() == "isPeripheral")) {
33 pp::VarDictionary message;
34 message.Set(
35 "isPeripheral",
36 pp::Var(PP_ToBool(GetTestingInterface()->IsPeripheral(pp_instance()))));
37 PostMessage(message);
38 }
39 }
40
41 class PowerSaverTestModule : public pp::Module {
42 public:
43 PowerSaverTestModule() : pp::Module() {}
44 virtual ~PowerSaverTestModule() {}
45
46 virtual pp::Instance* CreateInstance(PP_Instance instance) {
47 return new PowerSaverTestInstance(instance);
48 }
49 };
50
51 namespace pp {
52
53 Module* CreateModule() {
54 return new PowerSaverTestModule();
55 }
56
57 } // namespace pp
OLDNEW
« content/public/test/ppapi_test_utils.h ('K') | « ppapi/shared_impl/ppapi_constants.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698