File: chrome.py

package info (click to toggle)
plaso 20241006-4
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 673,228 kB
  • sloc: python: 91,831; sh: 557; xml: 97; makefile: 17; sql: 14; vhdl: 11
file content (47 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for the Google Chrome history custom event formatter helpers."""

import unittest

from plaso.formatters import chrome

from tests.formatters import test_lib


class ChromeHistoryTypedCountFormatterHelperTest(
    test_lib.EventFormatterTestCase):
  """Tests for the Google Chrome history typed count formatter helper."""

  def testFormatEventValues(self):
    """Tests the FormatEventValues function."""
    formatter_helper = chrome.ChromeHistoryTypedCountFormatterHelper()

    output_mediator = self._CreateOutputMediator()

    event_values = {'typed_count': 0}
    formatter_helper.FormatEventValues(output_mediator, event_values)
    self.assertEqual(
        event_values['url_typed_string'], '(URL not typed directly)')

    event_values = {'typed_count': 1}
    formatter_helper.FormatEventValues(output_mediator, event_values)
    self.assertEqual(
        event_values['url_typed_string'], '(URL typed 1 time)')

    event_values = {'typed_count': 3}
    formatter_helper.FormatEventValues(output_mediator, event_values)
    self.assertEqual(
        event_values['url_typed_string'], '(URL typed 3 times)')

    event_values = {'typed_count': -1}
    formatter_helper.FormatEventValues(output_mediator, event_values)
    self.assertEqual(event_values['url_typed_string'], -1)

    event_values = {'typed_count': None}
    formatter_helper.FormatEventValues(output_mediator, event_values)
    self.assertNotIn('url_typed_string', event_values)


if __name__ == '__main__':
  unittest.main()