~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to backend/wbprivate/workbench/unit-tests/wb_undo_methods.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
void reset_undo_accounting()
 
3
{
 
4
  last_undo_stack_height= um->get_undo_stack().size();
 
5
  last_redo_stack_height= um->get_redo_stack().size();
 
6
}
 
7
 
 
8
 
 
9
void check_only_one_undo_added_(const std::string &loc)
 
10
{
 
11
  ++last_undo_stack_height;
 
12
  if (um->get_undo_stack().size() != last_undo_stack_height)
 
13
    dump_history();
 
14
  ensure_equals(loc+": added 1 undo action", um->get_undo_stack().size(), last_undo_stack_height);
 
15
 
 
16
  // adding new stuff to the undo stack will clear the redo stack
 
17
  last_redo_stack_height= um->get_redo_stack().size();
 
18
}
 
19
#define check_only_one_undo_added() check_only_one_undo_added_(G_STRINGIFY(__LINE__))
 
20
 
 
21
 
 
22
// helper member functions
 
23
void check_undo_(const std::string &loc)
 
24
{
 
25
  ensure_equals(loc+":undo stack size", um->get_undo_stack().size(), last_undo_stack_height);
 
26
  ensure_equals(loc+":redo stack size", um->get_redo_stack().size(), last_redo_stack_height);
 
27
 
 
28
  // check that the latest undo action has a description
 
29
  ensure(loc+":undo action description is set", um->get_action_description() != "");
 
30
 
 
31
  // perform undo
 
32
  um->undo();
 
33
 
 
34
  --last_undo_stack_height;
 
35
  // redo stack should grow by 1 and undo shrink by 1
 
36
  ensure_equals(loc+":redo stack size after undo", um->get_redo_stack().size(), last_redo_stack_height+1);
 
37
  ensure_equals(loc+":undo stack size after undo", um->get_undo_stack().size(), last_undo_stack_height);
 
38
 
 
39
  last_redo_stack_height= um->get_redo_stack().size();
 
40
}
 
41
#define check_undo() check_undo_(G_STRINGIFY(__LINE__))
 
42
 
 
43
 
 
44
 
 
45
void check_redo_(const std::string &loc)
 
46
{
 
47
  // make sure that the undo/redo stack has the expected size
 
48
  ensure_equals(loc+":undo stack size", um->get_undo_stack().size(), last_undo_stack_height);
 
49
  ensure_equals(loc+":redo stack size", um->get_redo_stack().size(), last_redo_stack_height);
 
50
 
 
51
  // perform redo
 
52
  um->redo();
 
53
 
 
54
  ++last_undo_stack_height;
 
55
  ensure_equals(loc+":redo stack size after redo", um->get_redo_stack().size(), last_redo_stack_height-1);
 
56
  ensure_equals(loc+":undo stack size after redo", um->get_undo_stack().size(), last_undo_stack_height);
 
57
 
 
58
  last_redo_stack_height= um->get_redo_stack().size();
 
59
}
 
60
#define check_redo() check_redo_(G_STRINGIFY(__LINE__))
 
61
 
 
62
 
 
63
void dump_history()
 
64
{
 
65
  wbui->get_history_tree()->dump(0);
 
66
}