| 1 |
// -*- C++ -*- |
| 2 |
// $Id: TestLabelManagerFilter.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ |
| 3 |
|
| 4 |
// DYMO LabelWriter Drivers |
| 5 |
// Copyright (C) 2008 Sanford L.P. |
| 6 |
|
| 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. |
| 11 |
|
| 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. |
| 16 |
|
| 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. |
| 20 |
|
| 21 |
#include "TestCommon.h" |
| 22 |
#include "TestLabelManagerFilter.h" |
| 23 |
#include "MOCK_PrintEnvironment.h" |
| 24 |
#include "../LabelManagerDriver.h" |
| 25 |
#include "../CupsFilterLabelManager.h" |
| 26 |
#include <ostream> |
| 27 |
|
| 28 |
using namespace std; |
| 29 |
using namespace DymoPrinterDriver; |
| 30 |
|
| 31 |
// Registers the fixture into the 'registry' |
| 32 |
CPPUNIT_TEST_SUITE_REGISTRATION(LabelManagerFilterTest); |
| 33 |
|
| 34 |
LabelManagerFilterTest::LabelManagerFilterTest() |
| 35 |
{ |
| 36 |
PPDNames_.push_back("../../../ppd/lwduot.ppd"); |
| 37 |
PPDNames_.push_back("../../../ppd/lm400.ppd"); |
| 38 |
PPDNames_.push_back("../../../ppd/lm450.ppd"); |
| 39 |
PPDNames_.push_back("../../../ppd/lmpc.ppd"); |
| 40 |
PPDNames_.push_back("../../../ppd/lp350.ppd"); |
| 41 |
PPDNames_.push_back("../../../ppd/lwduot2.ppd"); |
| 42 |
PPDNames_.push_back("../../../ppd/lmpc2.ppd"); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
void |
| 47 |
LabelManagerFilterTest::setUp() |
| 48 |
{ |
| 49 |
ppds_.clear(); |
| 50 |
for (ppd_names_it it = PPDNames_.begin(); it < PPDNames_.end(); ++it) |
| 51 |
{ |
| 52 |
ppd_file_t* ppd = ppdOpenFile(it->c_str()); |
| 53 |
CPPUNIT_ASSERT(ppd != NULL); |
| 54 |
|
| 55 |
ppdMarkDefaults(ppd); |
| 56 |
ppds_[*it] = ppd; |
| 57 |
} |
| 58 |
|
| 59 |
Driver_ = new CLabelManagerDriver(Env_); |
| 60 |
LM_ = new CDummyLanguageMonitor(Env_); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
void |
| 65 |
LabelManagerFilterTest::tearDown() |
| 66 |
{ |
| 67 |
for (ppds_it it = ppds_.begin(); it != ppds_.end(); ++it) |
| 68 |
ppdClose(it->second); |
| 69 |
ppds_.clear(); |
| 70 |
|
| 71 |
delete Driver_; |
| 72 |
delete LM_; |
| 73 |
} |
| 74 |
|
| 75 |
void |
| 76 |
LabelManagerFilterTest::testAlignment() |
| 77 |
{ |
| 78 |
for (ppds_it it = ppds_.begin(); it != ppds_.end(); ++it) |
| 79 |
{ |
| 80 |
ppd_file_t* ppd = it->second; |
| 81 |
|
| 82 |
printf("Processing '%s'...\n", it->first.c_str()); |
| 83 |
|
| 84 |
ppdMarkOption(ppd, "DymoLabelAlignment", "Left"); |
| 85 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 86 |
CPPUNIT_ASSERT_EQUAL(CLabelManagerDriver::alLeft, Driver_->GetAlignment()); |
| 87 |
|
| 88 |
ppdMarkOption(ppd, "DymoLabelAlignment", "Center"); |
| 89 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 90 |
CPPUNIT_ASSERT_EQUAL(CLabelManagerDriver::alCenter, Driver_->GetAlignment()); |
| 91 |
|
| 92 |
ppdMarkOption(ppd, "DymoLabelAlignment", "Right"); |
| 93 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 94 |
CPPUNIT_ASSERT_EQUAL(CLabelManagerDriver::alRight, Driver_->GetAlignment()); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
void |
| 99 |
LabelManagerFilterTest::testCutOptions() |
| 100 |
{ |
| 101 |
for (ppds_it it = ppds_.begin(); it != ppds_.end(); ++it) |
| 102 |
{ |
| 103 |
ppd_file_t* ppd = it->second; |
| 104 |
|
| 105 |
printf("Processing '%s'...\n", it->first.c_str()); |
| 106 |
|
| 107 |
// not all ppds have the option |
| 108 |
if (!ppdFindOption(ppd, "DymoCutOptions")) |
| 109 |
continue; |
| 110 |
|
| 111 |
ppdMarkOption(ppd, "DymoCutOptions", "Cut"); |
| 112 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 113 |
CPPUNIT_ASSERT_EQUAL(CLabelManagerDriver::coCut, Driver_->GetCutOptions()); |
| 114 |
|
| 115 |
ppdMarkOption(ppd, "DymoCutOptions", "ChainMarks"); |
| 116 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 117 |
CPPUNIT_ASSERT_EQUAL(CLabelManagerDriver::coChainMarks, Driver_->GetCutOptions()); |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
void |
| 122 |
LabelManagerFilterTest::testContinuousPaper() |
| 123 |
{ |
| 124 |
for (ppds_it it = ppds_.begin(); it != ppds_.end(); ++it) |
| 125 |
{ |
| 126 |
ppd_file_t* ppd = it->second; |
| 127 |
|
| 128 |
printf("Processing '%s'...\n", it->first.c_str()); |
| 129 |
|
| 130 |
ppdMarkOption(ppd, "DymoContinuousPaper", "0"); |
| 131 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 132 |
CPPUNIT_ASSERT_EQUAL(false, Driver_->IsContinuousPaper()); |
| 133 |
|
| 134 |
ppdMarkOption(ppd, "DymoContinuousPaper", "1"); |
| 135 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 136 |
CPPUNIT_ASSERT_EQUAL(true, Driver_->IsContinuousPaper()); |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
void |
| 141 |
LabelManagerFilterTest::testTapeColor() |
| 142 |
{ |
| 143 |
for (ppds_it it = ppds_.begin(); it != ppds_.end(); ++it) |
| 144 |
{ |
| 145 |
ppd_file_t* ppd = it->second; |
| 146 |
|
| 147 |
printf("Processing '%s'...\n", it->first.c_str()); |
| 148 |
|
| 149 |
for (int i = 0; i < 13; ++i) |
| 150 |
{ |
| 151 |
char buf[10]; |
| 152 |
sprintf(buf, "%i", i); |
| 153 |
ppdMarkOption(ppd, "DymoTapeColor", buf); |
| 154 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 155 |
CPPUNIT_ASSERT_EQUAL(i, int(Driver_->GetTapeColor())); |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
void |
| 161 |
LabelManagerFilterTest::testDeviceSettings() |
| 162 |
{ |
| 163 |
ppd_file_t* ppd = ppdOpenFile("../../../ppd/lwduot.ppd"); |
| 164 |
CPPUNIT_ASSERT(ppd != NULL); |
| 165 |
ppdMarkDefaults(ppd); |
| 166 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 167 |
|
| 168 |
CPPUNIT_ASSERT_EQUAL(size_t(96), Driver_->GetMaxPrintableWidth()); |
| 169 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 170 |
CPPUNIT_ASSERT_EQUAL(size_t(61), Driver_->GetMinLeader()); |
| 171 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 172 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 173 |
CPPUNIT_ASSERT_EQUAL(true, Driver_->IsSupportAutoCut()); |
| 174 |
ppdClose(ppd); |
| 175 |
|
| 176 |
ppd = ppdOpenFile("../../../ppd/lwduot2.ppd"); |
| 177 |
CPPUNIT_ASSERT(ppd != NULL); |
| 178 |
ppdMarkDefaults(ppd); |
| 179 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 180 |
|
| 181 |
CPPUNIT_ASSERT_EQUAL(size_t(128), Driver_->GetMaxPrintableWidth()); |
| 182 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 183 |
CPPUNIT_ASSERT_EQUAL(size_t(61), Driver_->GetMinLeader()); |
| 184 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 185 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 186 |
CPPUNIT_ASSERT_EQUAL(true, Driver_->IsSupportAutoCut()); |
| 187 |
ppdClose(ppd); |
| 188 |
|
| 189 |
ppd = ppdOpenFile("../../../ppd/lm450.ppd"); |
| 190 |
CPPUNIT_ASSERT(ppd != NULL); |
| 191 |
ppdMarkDefaults(ppd); |
| 192 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 193 |
|
| 194 |
CPPUNIT_ASSERT_EQUAL(size_t(128), Driver_->GetMaxPrintableWidth()); |
| 195 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 196 |
CPPUNIT_ASSERT_EQUAL(size_t(55), Driver_->GetMinLeader()); |
| 197 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 198 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 199 |
CPPUNIT_ASSERT_EQUAL(true, Driver_->IsSupportAutoCut()); |
| 200 |
ppdClose(ppd); |
| 201 |
|
| 202 |
ppd = ppdOpenFile("../../../ppd/lm400.ppd"); |
| 203 |
CPPUNIT_ASSERT(ppd != NULL); |
| 204 |
ppdMarkDefaults(ppd); |
| 205 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 206 |
|
| 207 |
CPPUNIT_ASSERT_EQUAL(size_t(96), Driver_->GetMaxPrintableWidth()); |
| 208 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 209 |
CPPUNIT_ASSERT_EQUAL(size_t(55), Driver_->GetMinLeader()); |
| 210 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 211 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 212 |
CPPUNIT_ASSERT_EQUAL(true, Driver_->IsSupportAutoCut()); |
| 213 |
|
| 214 |
ppd = ppdOpenFile("../../../ppd/lp350.ppd"); |
| 215 |
CPPUNIT_ASSERT(ppd != NULL); |
| 216 |
ppdMarkDefaults(ppd); |
| 217 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 218 |
|
| 219 |
CPPUNIT_ASSERT_EQUAL(size_t(96), Driver_->GetMaxPrintableWidth()); |
| 220 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 221 |
CPPUNIT_ASSERT_EQUAL(size_t(55), Driver_->GetMinLeader()); |
| 222 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 223 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 224 |
CPPUNIT_ASSERT_EQUAL(false, Driver_->IsSupportAutoCut()); |
| 225 |
|
| 226 |
ppd = ppdOpenFile("../../../ppd/lmpc.ppd"); |
| 227 |
CPPUNIT_ASSERT(ppd != NULL); |
| 228 |
ppdMarkDefaults(ppd); |
| 229 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 230 |
|
| 231 |
CPPUNIT_ASSERT_EQUAL(size_t(96), Driver_->GetMaxPrintableWidth()); |
| 232 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 233 |
CPPUNIT_ASSERT_EQUAL(size_t(55), Driver_->GetMinLeader()); |
| 234 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 235 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 236 |
CPPUNIT_ASSERT_EQUAL(false, Driver_->IsSupportAutoCut()); |
| 237 |
ppdClose(ppd); |
| 238 |
|
| 239 |
ppd = ppdOpenFile("../../../ppd/lmpc2.ppd"); |
| 240 |
CPPUNIT_ASSERT(ppd != NULL); |
| 241 |
ppdMarkDefaults(ppd); |
| 242 |
CDriverInitializerLabelManager::ProcessPPDOptions(*Driver_, *LM_, ppd); |
| 243 |
|
| 244 |
CPPUNIT_ASSERT_EQUAL(size_t(128), Driver_->GetMaxPrintableWidth()); |
| 245 |
CPPUNIT_ASSERT_EQUAL(size_t(75), Driver_->GetNormalLeader()); |
| 246 |
CPPUNIT_ASSERT_EQUAL(size_t(55), Driver_->GetMinLeader()); |
| 247 |
CPPUNIT_ASSERT_EQUAL(size_t(43), Driver_->GetAlignedLeader()); |
| 248 |
CPPUNIT_ASSERT_EQUAL(size_t(133), Driver_->GetMinPageLines()); |
| 249 |
CPPUNIT_ASSERT_EQUAL(false, Driver_->IsSupportAutoCut()); |
| 250 |
ppdClose(ppd); |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
/* |
| 255 |
* End of "$Id: TestLabelManagerFilter.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". |
| 256 |
*/ |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|