def testParse(self): """Tests the Parse function.""" parser = android_app_usage.AndroidAppUsageParser() storage_writer = self._ParseFile(['usage-history.xml'], parser) self.assertEqual(storage_writer.number_of_warnings, 0) self.assertEqual(storage_writer.number_of_events, 28) events = list(storage_writer.GetEvents()) expected_event_values = { 'data_type': 'android:event:last_resume_time', 'component': ('com.sec.android.widgetapp.ap.hero.accuweather.menu.MenuAdd'), 'package': 'com.sec.android.widgetapp.ap.hero.accuweather', 'timestamp': '2013-12-09 19:28:33.047000' } self.CheckEventValues(storage_writer, events[22], expected_event_values) expected_event_values = { 'data_type': 'android:event:last_resume_time', 'component': 'com.google.android.gsf.login.NameActivity', 'package': 'com.google.android.gsf.login', 'timestamp': '2013-09-27 19:45:55.675000' } self.CheckEventValues(storage_writer, events[17], expected_event_values)
def testParse(self): """Tests the Parse function.""" parser = android_app_usage.AndroidAppUsageParser() storage_writer = self._ParseFile( ['usage-history.xml'], parser) self.assertEqual(storage_writer.number_of_warnings, 0) self.assertEqual(storage_writer.number_of_events, 28) events = list(storage_writer.GetEvents()) event = events[22] self.CheckTimestamp(event.timestamp, '2013-12-09 19:28:33.047000') event_data = self._GetEventDataOfEvent(storage_writer, event) self.assertEqual( event_data.component, 'com.sec.android.widgetapp.ap.hero.accuweather.menu.MenuAdd') expected_message = ( 'Package: ' 'com.sec.android.widgetapp.ap.hero.accuweather ' 'Component: ' 'com.sec.android.widgetapp.ap.hero.accuweather.menu.MenuAdd') expected_short_message = ( 'Package: com.sec.android.widgetapp.ap.hero.accuweather ' 'Component: com.sec.and...') self._TestGetMessageStrings( event_data, expected_message, expected_short_message) event = events[17] event_data = self._GetEventDataOfEvent(storage_writer, event) self.CheckTimestamp(event.timestamp, '2013-09-27 19:45:55.675000') self.assertEqual(event_data.package, 'com.google.android.gsf.login') expected_message = ( 'Package: ' 'com.google.android.gsf.login ' 'Component: ' 'com.google.android.gsf.login.NameActivity') expected_short_message = ( 'Package: com.google.android.gsf.login ' 'Component: com.google.android.gsf.login...') self._TestGetMessageStrings( event_data, expected_message, expected_short_message)
def testParse(self): """Tests the Parse function.""" parser_object = android_app_usage.AndroidAppUsageParser() test_file = self._GetTestFilePath([u'usage-history.xml']) event_queue_consumer = self._ParseFile(parser_object, test_file) event_objects = self._GetEventObjectsFromQueue(event_queue_consumer) self.assertEqual(len(event_objects), 28) event_object = event_objects[22] expected_timestamp = timelib.Timestamp.CopyFromString( u'2013-12-09 19:28:33.047000') self.assertEqual(event_object.timestamp, expected_timestamp) self.assertEqual( event_object.component, u'com.sec.android.widgetapp.ap.hero.accuweather.menu.MenuAdd') expected_msg = ( u'Package: ' u'com.sec.android.widgetapp.ap.hero.accuweather ' u'Component: ' u'com.sec.android.widgetapp.ap.hero.accuweather.menu.MenuAdd') expected_msg_short = ( u'Package: com.sec.android.widgetapp.ap.hero.accuweather ' u'Component: com.sec.and...') self._TestGetMessageStrings(event_object, expected_msg, expected_msg_short) event_object = event_objects[17] expected_timestamp = timelib.Timestamp.CopyFromString( u'2013-09-27 19:45:55.675000') self.assertEqual(event_object.timestamp, expected_timestamp) self.assertEqual(event_object.package, u'com.google.android.gsf.login') expected_msg = (u'Package: ' u'com.google.android.gsf.login ' u'Component: ' u'com.google.android.gsf.login.NameActivity') expected_msg_short = (u'Package: com.google.android.gsf.login ' u'Component: com.google.android.gsf.login...') self._TestGetMessageStrings(event_object, expected_msg, expected_msg_short)
def setUp(self): """Makes preparations before running an individual test.""" self._parser = android_app_usage.AndroidAppUsageParser()
def setUp(self): """Sets up the needed objects used throughout the test.""" self._parser = android_app_usage.AndroidAppUsageParser()