~ubuntu-branches/ubuntu/vivid/debtags/vivid-proposed

« back to all changes in this revision

Viewing changes to libapt-front/apt-front/cache/component/history.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Zini
  • Date: 2006-03-18 20:31:47 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060318203147-d9uzdeong5f5nk14
Tags: 1.5.5
* Added dumpavail command.
* Don't rebuild the database on install: apt-index-watcher does it instead.
  Closes: #357103.
* Compiles with g++ 4.1.  Closes: #357360.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
   @file cache/component/history.cpp
3
 
   @author Peter Rockai <me@mornfall.net>
4
 
*/
5
 
 
6
 
#include <apt-front/cache/component/history.h>
7
 
#include <apt-front/cache/component/state.h>
8
 
 
9
 
using namespace aptFront::cache;
10
 
using namespace aptFront::cache::component;
11
 
 
12
 
#ifdef COMPILE_TESTSUITE
13
 
#include "test-utils.h"
14
 
 
15
 
namespace tut {
16
 
 
17
 
struct cache_component_history_shar {
18
 
    Cache c;
19
 
    cache_component_history_shar() {
20
 
        aptInit();
21
 
        c.open( Cache::OpenDefault | Cache::OpenReadOnly );
22
 
        c.addComponent( new History<State>() );
23
 
    }
24
 
};
25
 
 
26
 
TESTGRP( cache_component_history );
27
 
 
28
 
template<> template<>
29
 
void to::test<1>()
30
 
{
31
 
    History<State> &s = c.component<History<State> >();
32
 
    entity::Package p = c.packages().packageByName( "exim4" );
33
 
    while (!p.canInstall()) {
34
 
        p = p.nextInCache();
35
 
    }
36
 
    s.checkpoint();
37
 
    p.markInstall();
38
 
    ensure( p.markedInstall() );
39
 
    ensure( !s.canRedo() );
40
 
    ensure( s.canUndo() );
41
 
    s.undo();
42
 
    ensure( !s.canUndo() );
43
 
    ensure( !p.markedInstall() );
44
 
    ensure( s.canRedo() );
45
 
    s.redo();
46
 
    ensure( !s.canRedo() );
47
 
    ensure( p.markedInstall() );
48
 
    s.undo();
49
 
    s.checkpoint();
50
 
    p.markInstall();
51
 
    ensure( p.markedInstall() );
52
 
    ensure( !s.canRedo() );
53
 
    ensure( s.canUndo() );
54
 
    s.undo();
55
 
    ensure( !p.markedInstall() );
56
 
    ensure( s.canRedo() );
57
 
    ensure( !s.canUndo() );
58
 
}
59
 
 
60
 
template<> template<>
61
 
void to::test<2>()
62
 
{
63
 
    History<State> &s = c.component<History<State> >();
64
 
    entity::Package p = c.packages().packageByName( "exim4" );
65
 
    while (!p.canInstall()) {
66
 
        p = p.nextInCache();
67
 
    }
68
 
    s.checkpoint();
69
 
    p.markInstall();
70
 
    ensure( p.markedInstall() );
71
 
    ensure( !s.canRedo() );
72
 
    ensure( s.canUndo() );
73
 
    s.undo();
74
 
    ensure( !s.canUndo() );
75
 
    ensure( !p.markedInstall() );
76
 
    ensure( s.canRedo() );
77
 
    c.reopen();
78
 
    ensure( !s.canUndo() );
79
 
    ensure( !s.canRedo() );
80
 
}
81
 
 
82
 
template<> template<>
83
 
void to::test<3>()
84
 
{
85
 
    History<State> &s = c.component<History<State> >();
86
 
    entity::Package p = c.packages().packageByName( "exim4" );
87
 
    while (!p.canInstall()) {
88
 
        p = p.nextInCache();
89
 
    }
90
 
    s.checkpoint();
91
 
    p.markInstall();
92
 
    ensure( p.markedInstall() );
93
 
    ensure( !s.canRedo() );
94
 
    ensure( s.canUndo() );
95
 
    s.undo();
96
 
    ensure( !s.canUndo() );
97
 
    ensure( !p.markedInstall() );
98
 
    ensure( s.canRedo() );
99
 
    s.redo();
100
 
    c.reopen();
101
 
    ensure( !s.canUndo() );
102
 
    ensure( !s.canRedo() );
103
 
}
104
 
 
105
 
template<> template<>
106
 
void to::test<4>()
107
 
{
108
 
    History<State> &s = c.component<History<State> >();
109
 
    entity::Package p = c.packages().packageByName( "exim4" );
110
 
    while (!p.canInstall()) {
111
 
        p = p.nextInCache();
112
 
    }
113
 
    s.setAutoCheckpoint( true );
114
 
    p.markInstall();
115
 
    ensure( p.markedInstall() );
116
 
    ensure( !s.canRedo() );
117
 
    ensure( s.canUndo() );
118
 
    s.undo();
119
 
    ensure( !s.canUndo() );
120
 
    ensure( !p.markedInstall() );
121
 
    ensure( s.canRedo() );
122
 
    s.redo();
123
 
    c.reopen();
124
 
    ensure( !s.canUndo() );
125
 
    ensure( !s.canRedo() );
126
 
    p = c.packages().packageByName( "exim4" );
127
 
    while (!p.canInstall()) {
128
 
        p = p.nextInCache();
129
 
    }
130
 
    p.markInstall();
131
 
    ensure( s.canUndo() );
132
 
    ensure( !s.canRedo() );
133
 
    p.markRemove();
134
 
    ensure( s.canUndo() );
135
 
    ensure( !s.canRedo() );
136
 
    s.undo();
137
 
    ensure( s.canUndo() );
138
 
    ensure( s.canRedo() );
139
 
    s.undo();
140
 
    ensure( !s.canUndo() );
141
 
    s.redo();
142
 
    ensure( s.canUndo() );
143
 
    ensure( s.canRedo() );
144
 
}
145
 
 
146
 
}
147
 
 
148
 
#endif