- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / activity_log_private / README
1 This directory contains tests for chrome extension activity logging.
2
3 The tests use two chrome extensions:
4   -test  : sends messages to the friend extension and listens for activity
5            logged by the friend extension. Checks the activity has been logged
6            correctly.
7   -friend: recieves messages from the extension and runs a function based on
8            the contents of the message.
9
10
11 Adding a new test:
12
13   In friend/reply.js:
14     (1) Add a function to call the chrome api calls you want to test. If you
15         need to use window.open please consider adding your code to
16         executeApiCallsOnTabUpdated or executeDOMChangesOnTabUpdated. Every
17         extra window.open call will slow down the tests by 3s and may cause
18         timeouts.
19     (2) Add the name of the new function to the function map (fnMap).
20
21     IMPORTANT NOTES for adding tests:
22       - The function should clean up any changes it made (e.g. listeners
23         it added) before finishing. If they are not cleaned up then unexpected
24         behavior can happen in test cases that run after this function.
25       - Every window.open call can add 3 secs to the test run for debug builds.
26         Making lots of window.open calls will therefore cause the tests to
27         timeout. If your test needs to use window.open please consider adding
28         it to one of the following existing functions:
29           - executeApiCallsOnTabUpdated
30           - executeDOMChangesOnTabUpdated
31
32   In friend/options.html:
33     (1) Add a button to allow the new function to be called in manual mode.
34
35   You may need also to modify the manifest.json and other files in the
36   friend extension directory.
37
38   In test/test.js:
39     (1) Add the test to the testcase array.
40
41         You will need to define the function that sends a message to the
42         friend extension and define the expected activity logging. Example:
43
44         testCases.push({
45           func: function triggerMyFunctionCall() {
46              chrome.runtime.sendMessage(FRIEND_EXTENSION_ID,
47                                         'my_function_call_id',
48                                         function response() { });
49           },
50           expected_activity: ['api.call1', 'api.call2', 'api.call3']
51         });
52
53         where 'my_function_call_id' is the key you added to the fn_map in
54         reply.js.
55
56
57 Running a testcase in Incognito mode:
58   
59   To check logging when run in incognito mode, add the following to the
60   testcase:
61       
62       is_incognito: true
63
64   This will automatically cause all new tabs to be opened in incognito mode and
65   check the url information has been correctly cleaned.  
66
67
68 Configuring a testcase for a particular OS:  
69   
70   If you need to disable a test for a particular OS then you can do this by
71   adding the disabled field to the test case. For example:
72        
73        disabled:  {win: true, mac: true}
74
75   If you need to configure different expected activity for a particular OS, you
76   can override the logging. E.g.:
77
78        expected_activity_win: ['api.call1', 'api.call2', 'api.call3']
79        expected_activity_mac: ['api.call1', 'api.call2', 'api.call3']
80        
81   See the chrome.runtime.getPlatformInfo documentation for details of which OS
82   names to use.
83
84
85 Running the tests:
86
87   > out/Debug/browser_tests --gtest_filter=ActivityLogApiTest.TriggerEvent
88
89
90 Running in manual mode:
91
92   (1) Start chrome with out/Debug/chrome
93   (2) Navigate to chrome://extensions
94   (3) Install the friend and test extensions from your chrome src folder
95   (4) Click on the "options" link under the friend extension
96   (5) You should see the options page the buttons to run the functions manually