1# Copyright 2015 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6class Failure(Exception):
7  """StoryTest Exception raised when an undesired but designed-for problem."""
8
9
10class StoryTest(object):
11  """A class for creating story tests.
12
13  The overall test run control flow follows this order:
14    test.WillRunStory
15    state.WillRunStory
16    state.RunStory
17    test.Measure
18    state.DidRunStory
19    test.DidRunStory
20  """
21
22  def WillRunStory(self, platform):
23    """Override to do any action before running the story.
24
25    This is run before state.WillRunStory.
26    Args:
27      platform: The platform that the story will run on.
28    """
29    raise NotImplementedError()
30
31  def Measure(self, platform, results):
32    """Override to take the measurement.
33
34    This is run only if state.RunStory is successful.
35    Args:
36      platform: The platform that the story will run on.
37      results: The results of running the story.
38    """
39    raise NotImplementedError()
40
41  def DidRunStory(self, platform):
42    """Override to do any action after running the story, e.g., clean up.
43
44    This is run after state.DidRunStory. And this is always called even if the
45    test run failed.
46    Args:
47      platform: The platform that the story will run on.
48    """
49    raise NotImplementedError()
50