aboutsummaryrefslogtreecommitdiff
path: root/wlauto/workloads/facebook/__init__.py
blob: cbc9a7c831d870763573c674ed53907b8ca40cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#    Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


import os
import time
import sys

from wlauto import AndroidUiAutoBenchmark
from wlauto import UiAutomatorWorkload
from wlauto import AndroidBenchmark


class Facebook(AndroidUiAutoBenchmark):

    name = 'facebook'
    description = """
    Uses com.facebook.patana apk for facebook workload.
    This workload does the following activities in facebook

        Login to facebook account.
        Send a message.
        Check latest notification.
        Search particular user account and visit his/her facebook account.
        Find friends.
        Update the facebook status

    [NOTE:  This workload starts disableUpdate workload as a part of setup to
    disable online updates, which helps to tackle problem of uncertain
    behavier during facebook workload run.]

    """
    package = 'com.facebook.katana'
    activity = '.LoginActivity'

    #'du' specify 'disable update'
    du_activity = 'com.android.vending/.AssetBrowserActivity'
    du_method_string = 'com.arm.wlauto.uiauto.facebook.UiAutomation#disableUpdate'
    du_jar_file = '/data/local/wa_usecases/com.arm.wlauto.uiauto.facebook.jar'
    du_run_timeout = 4 * 60
    du_working_dir = '/data/local/wa_usecases'
    du_apk_file = '/disableupdateapk/com.android.vending-4.3.10.apk'
    DELAY = 5

    def setup(self, context):
        UiAutomatorWorkload.setup(self, context)

        #Start the play store activity
        self.device.execute('am start {}'.format(self.du_activity))

        #Creating command
        command = 'uiautomator runtest {} -e workdir {} -c {}'.format(self.du_jar_file,
                                                                      self.du_working_dir,
                                                                      self.du_method_string)

        #Start the disable update workload
        self.device.execute(command, self.du_run_timeout)
        time.sleep(self.DELAY)

        #Stop the play store activity
        self.device.execute('am force-stop com.android.vending')

        AndroidBenchmark.setup(self, context)

    def update_result(self, context):
        super(Facebook, self).update_result(context)

    def teardown(self, context):
        pass