1 // Copyright (c) 2013 Intel Corporation. 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 #ifndef XWALK_EXTENSIONS_TEST_INTERNAL_EXTENSION_BROWSERTEST_H_
6 #define XWALK_EXTENSIONS_TEST_INTERNAL_EXTENSION_BROWSERTEST_H_
11 #include "base/timer/timer.h"
12 #include "xwalk/extensions/browser/xwalk_extension_function_handler.h"
13 #include "xwalk/extensions/common/xwalk_extension.h"
15 using xwalk::extensions::XWalkExtensionFunctionHandler;
16 using xwalk::extensions::XWalkExtensionFunctionInfo;
18 class TestExtension : public xwalk::extensions::XWalkExtension {
22 xwalk::extensions::XWalkExtensionInstance* CreateInstance() override;
25 class TestExtensionInstance
26 : public xwalk::extensions::XWalkExtensionInstance {
28 typedef std::vector<std::pair<std::string, int> > Database;
30 TestExtensionInstance();
31 virtual ~TestExtensionInstance();
33 void HandleMessage(scoped_ptr<base::Value> msg) override;
35 Database* database() { return &database_; }
38 void OnClearDatabase(scoped_ptr<XWalkExtensionFunctionInfo> info);
39 void OnAddPerson(scoped_ptr<XWalkExtensionFunctionInfo> info);
40 void OnAddPersonObject(scoped_ptr<XWalkExtensionFunctionInfo> info);
41 void OnGetAllPersons(scoped_ptr<XWalkExtensionFunctionInfo> info);
42 void OnGetPersonAge(scoped_ptr<XWalkExtensionFunctionInfo> info);
43 void OnStartHeartbeat(scoped_ptr<XWalkExtensionFunctionInfo> info);
44 void OnStopHeartbeat(scoped_ptr<XWalkExtensionFunctionInfo> info);
46 void DispatchHeartbeat();
48 std::vector<std::pair<std::string, int> > database_;
51 scoped_ptr<XWalkExtensionFunctionInfo> heartbeat_info_;
52 base::RepeatingTimer<TestExtensionInstance> timer_;
54 XWalkExtensionFunctionHandler handler_;
57 #endif // XWALK_EXTENSIONS_TEST_INTERNAL_EXTENSION_BROWSERTEST_H_