Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / test / src / test_modes.cpp
blob65cfd6db7ab6f4931e0ed6c99bd293b39f8f6eb8
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "TaskEventsPrint.hpp"
24 #include "harness_flight.hpp"
25 #include "Engine/Waypoint/Waypoints.hpp"
27 static bool
28 test_abort(int n_wind)
30 GlidePolar glide_polar(fixed(2));
31 Waypoints waypoints;
32 SetupWaypoints(waypoints);
34 if (verbose)
35 PrintDistanceCounts();
37 TaskBehaviour task_behaviour;
38 task_behaviour.SetDefaults();
39 task_behaviour.DisableAll();
40 task_behaviour.enable_trace = false;
42 TaskManager task_manager(task_behaviour, waypoints);
44 TaskEventsPrint default_events(verbose);
45 task_manager.SetTaskEvents(default_events);
47 task_manager.SetGlidePolar(glide_polar);
49 test_task(task_manager, waypoints, 1);
51 task_manager.Abort();
52 task_report(task_manager, "abort");
54 autopilot_parms.goto_target = true;
55 return run_flight(task_manager, autopilot_parms, n_wind);
58 static bool
59 test_goto(int n_wind, unsigned id, bool auto_mc)
61 GlidePolar glide_polar(fixed(2));
62 Waypoints waypoints;
63 SetupWaypoints(waypoints);
65 if (verbose)
66 PrintDistanceCounts();
68 TaskBehaviour task_behaviour;
69 task_behaviour.SetDefaults();
70 task_behaviour.DisableAll();
71 task_behaviour.auto_mc = auto_mc;
72 task_behaviour.enable_trace = false;
74 TaskManager task_manager(task_behaviour, waypoints);
76 TaskEventsPrint default_events(verbose);
77 task_manager.SetTaskEvents(default_events);
79 task_manager.SetGlidePolar(glide_polar);
81 test_task(task_manager, waypoints, 1);
83 task_manager.DoGoto(*waypoints.LookupId(id));
84 task_report(task_manager, "goto");
86 waypoints.Clear(); // clear waypoints so abort wont do anything
88 autopilot_parms.goto_target = true;
89 return run_flight(task_manager, autopilot_parms, n_wind);
92 static bool
93 test_null()
95 GlidePolar glide_polar(fixed(2));
96 Waypoints waypoints;
97 SetupWaypoints(waypoints);
99 if (verbose)
100 PrintDistanceCounts();
102 TaskBehaviour task_behaviour;
103 task_behaviour.SetDefaults();
104 task_behaviour.DisableAll();
105 task_behaviour.enable_trace = false;
107 TaskManager task_manager(task_behaviour, waypoints);
109 TaskEventsPrint default_events(verbose);
110 task_manager.SetTaskEvents(default_events);
112 task_manager.SetGlidePolar(glide_polar);
114 task_report(task_manager, "null");
116 waypoints.Clear(); // clear waypoints so abort wont do anything
118 autopilot_parms.goto_target = true;
119 return run_flight(task_manager, autopilot_parms, 0);
123 main(int argc, char** argv)
125 // default arguments
126 autopilot_parms.SetIdeal();
128 if (!ParseArgs(argc, argv))
129 return 0;
131 plan_tests(4);
133 ok(test_abort(0), "abort", 0);
134 ok(test_goto(0, 5, false), "goto", 0);
135 ok(test_goto(0, 5, true), "goto with auto mc", 0);
136 ok(test_null(), "null", 0);
138 return exit_status();