Imported Upstream version 17.23.5
[platform/upstream/libzypp.git] / tests / zypp / ProgressData_test.cc
1
2 #include <iostream>
3 #include <fstream>
4 #include <list>
5 #include <string>
6
7 #include <zypp/base/Logger.h>
8 #include <zypp/base/Exception.h>
9
10 #include <boost/test/unit_test.hpp>
11
12 #include <zypp/ProgressData.h>
13
14 using boost::unit_test::test_case;
15
16 using namespace zypp;
17
18 BOOST_AUTO_TEST_CASE(progressdata_test)
19 {
20   {
21     ProgressData progress(100);
22     CombinedProgressData sub1rcv(progress, 80);
23     
24     ProgressData sub1progress(100);
25     sub1progress.sendTo(sub1rcv);
26     
27     // task 1 goes to 50%
28     sub1progress.set(50);
29     // which is 50% of 80% in task 1
30     BOOST_CHECK_EQUAL( progress.val(), 40 );
31   }
32   
33   {
34     ProgressData progress(40000);
35     CombinedProgressData sub2rcv(progress, 10000);
36     
37     ProgressData sub2progress(500);
38     sub2progress.sendTo(sub2rcv);
39     sub2progress.set(250);
40     
41     // which is 50% of 80% in task 1
42     BOOST_CHECK_EQUAL( progress.val(), 5000 );
43   }
44   
45   {
46     ProgressData progress(20000,60000);
47     CombinedProgressData sub2rcv(progress, 10000);
48     
49     ProgressData sub2progress(500);
50     sub2progress.sendTo(sub2rcv);
51     sub2progress.set(250);
52     
53     // which is 50% of 80% in task 1
54     BOOST_CHECK_EQUAL( progress.val(), 25000 );
55   }
56   
57 }
58    
59