1# Copyright 2016 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6import random 7 8from pylib import constants 9from pylib.base import test_instance 10 11 12_SINGLE_EVENT_TIMEOUT = 100 # Milliseconds 13 14class MonkeyTestInstance(test_instance.TestInstance): 15 16 def __init__(self, args, _): 17 super().__init__() 18 19 self._categories = args.categories 20 self._event_count = args.event_count 21 self._seed = args.seed or random.randint(1, 100) 22 self._throttle = args.throttle 23 self._verbose_count = args.verbose_count 24 25 self._package = constants.PACKAGE_INFO[args.browser].package 26 self._activity = constants.PACKAGE_INFO[args.browser].activity 27 28 self._timeout_s = ( 29 self.event_count * (self.throttle + _SINGLE_EVENT_TIMEOUT)) / 1000 30 31 #override 32 def TestType(self): 33 return 'monkey' 34 35 #override 36 def SetUp(self): 37 pass 38 39 #override 40 def TearDown(self): 41 pass 42 43 @property 44 def activity(self): 45 return self._activity 46 47 @property 48 def categories(self): 49 return self._categories 50 51 @property 52 def event_count(self): 53 return self._event_count 54 55 @property 56 def package(self): 57 return self._package 58 59 @property 60 def seed(self): 61 return self._seed 62 63 @property 64 def throttle(self): 65 return self._throttle 66 67 @property 68 def timeout(self): 69 return self._timeout_s 70 71 @property 72 def verbose_count(self): 73 return self._verbose_count 74