%%
%% This is file `hycolor-test3.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hycolor.dtx  (with options: `test,test3')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007-2009 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file hycolor.dtx
%% and the derived files
%%    hycolor.sty, hycolor.pdf, hycolor.ins, hycolor.drv,
%%    xcolor-patch.sty, hycolor-test1.tex, hycolor-test2.tex,
%%    hycolor-test3.tex, hycolor-test-xcol1.tex,
%%    hycolor-test-xcol2.tex, hycolor-test-xcol3.tex,
%%    hycolor-test-xcol4.tex.
%% 
\ProvidesFile{hycolor-test3.tex}[2009/12/12 test file 3]
\documentclass{article}

\usepackage{qstest}
\IncludeTests{*}
\LogTests{log}{*}{*}

\makeatletter

\newcommand*{\TestPackageName}{test-package}
\newcommand*{\TestOptionName}{test-option}

\newcommand\Message{}
\def\Message#1#{\immediate\write16}

\newcommand*{\ExpectError}[2]{%
  \begingroup
    \global\let\saved@errhelp\errhelp
    \global\let\saved@errmessage\errmessage
    \let\errhelp\@gobble
    \def\errmessage##1{%
      \xdef\@ExpectErrorMessage{##1}%
    }%
    \PackageError\TestPackageName{#1}\@ehc
    \def\errhelp##1{%
      \global\let\errhelp\saved@errhelp
    }%
    \global\let\@ResultErrorMessage\@empty
    \def\errmessage##1{%
      \xdef\@ResultErrorMessage{##1}%
      \global\let\errmessage\saved@errmessage
      % \Message{[ ##1}%
      % \Message{] (ignored error)}%
      % \Message{}%
    }%
    #2%
  \endgroup
  \Expect*{\@ResultErrorMessage}*{\@ExpectErrorMessage}%
}
\usepackage{scrlfile}
\usepackage{hycolor}[2009/12/12]
\def\atfi@SETRGBCOLORtest{set-rgb}
\def\atfi@SETGRAYCOLORtest{set-gray}
\def\atfi@SETCMYKCOLORtest{set-cmyk}
\def\Test#1#2#3#4#5{%
  \begingroup
    \setbox0=\hbox{%
      \begingroup
        \chardef\HyColor@PdfVersion=6 %
        \HyColor@AttachfileColor{#1}\spec\inlinemacro\annot
            \TestPackageName\TestOptionName
        \edef\inline{\inlinemacro{test}}%
        \expandafter\Expect\expandafter{\spec}{#2}%
        \expandafter\Expect\expandafter{\inline}{#3}%
        \expandafter\Expect\expandafter{\annot}{#4}%
      \endgroup
      \begingroup
        \chardef\HyColor@PdfVersion=7 %
        \HyColor@AttachfileColor{#1}\spec\inlinemacro\annot
            \TestPackageName\TestOptionName
        \edef\inline{\inlinemacro{test}}%
        \expandafter\Expect\expandafter{\spec}{#2}%
        \expandafter\Expect\expandafter{\inline}{#3}%
        \expandafter\Expect\expandafter{\annot}{#5}%
      \endgroup
    }%
    \Expect*{\the\wd0}{0.0pt}%
  \endgroup
}
\newif\ifError
\def\TestError[#1]#2#3#4#5#6{%
  \begingroup
    \global\Errorfalse
    \let\OrgPackageError\PackageError
    \def\PackageError##1##2##3{%
      \edef\TestTemp{##1}%
      \ifx\TestTemp\TestPackageName
        \Expect*{\ifError too many errors\else ok\fi}{ok}%
        \Expect*{#6}*{##2}%
        \global\Errortrue
      \else
        \OrgPackageError{##1}{##2}{##3}%
      \fi
    }%
    \setbox0=\hbox{%
      \begingroup
        \chardef\HyColor@PdfVersion=#1 %
        \HyColor@AttachfileColor{#2}\spec\inlinemacro\annot
            \TestPackageName\TestOptionName
        \edef\inline{\inlinemacro{test}}%
        \expandafter\Expect\expandafter{\spec}{#3}%
        \expandafter\Expect\expandafter{\inline}{#4}%
        \expandafter\Expect\expandafter{\annot}{#5}%
      \endgroup
      \ifx\\#6\\%
      \else
        \Expect*{\ifError ok\else missing error\fi}{ok}%
      \fi
    }%
    \Expect*{\the\wd0}{0.0pt}%
  \endgroup
}
\def\NoEmptyModel{%
  Color model `empty' is not permitted for option `\TestOptionName'%
}
\def\ModelNoXcolor#1#2{%
  Color model `#1' is not supported\MessageBreak
  without package `xcolor' in\MessageBreak
  `\TestOptionName=[#1]{#2}'% hash-ok
}
\def\SpecNoXColor#1{%
  This color specification is not supported\MessageBreak
  without package `xcolor' in\MessageBreak
  `test-option=#1'%
}
\begin{qstest}{AttachfileColor}{AttachfileColor}
  \Test{}{}{}{}{}%
  \Test{0.1 0.2 0.3}{[rgb]{.1,.2,.3}}{.1 .2 .3 set-rgb}%
       {/C[.1 .2 .3]}{/C[.1 .2 .3]}%
  \Test{[gray]{0.4}}{[gray]{0.4}}{.4 set-gray}%
       {/C[.4 .4 .4]}{/C[.4]}%
  \Test{[rgb]{0.3,.2,.1}}{[rgb]{0.3,.2,.1}}{.3 .2 .1 set-rgb}%
       {/C[.3 .2 .1]}{/C[.3 .2 .1]}%
  \Test{0.0 1.0 1}{[rgb]{0,1,1}}{0 1 1 set-rgb}%
       {/C[0 1 1]}{/C[0 1 1]}%
  \Test{[gray]1}{[gray]1}{1 set-gray}{/C[1 1 1]}{/C[1]}%
  \TestError[6]{[empty]{}}{}{}{}\NoEmptyModel
  \TestError[7]{[empty]{}}{}{}{}\NoEmptyModel
  \TestError[6]{[cmyk]{.1,.2,.3,.4}}{[cmyk]{.1,.2,.3,.4}}%
            {.1 .2 .3 .4 set-cmyk}{}%
            {\ModelNoXcolor{cmyk}{.1,.2,.3,.4}}%
  \TestError[7]{[cmyk]{.1,.2,.3,.4}}{[cmyk]{.1,.2,.3,.4}}%
            {.1 .2 .3 .4 set-cmyk}{/C[.1 .2 .3 .4]}{}%
  \TestError[6]{red}{red}{}{}{\SpecNoXColor{red}}%
  \TestError[7]{red}{red}{}{}{\SpecNoXColor{red}}%
\end{qstest}
\usepackage{xcolor}
\definecolor[named]{MyGreen}{rgb}{0,0.7,0}
\definecolor{mygreen}{named}{MyGreen}
\definecolor{graynine}{gray}{0.9}
\definecolor{GraySix}{Gray}{9}
\begin{qstest}{AttachfileColorX}{AttachfileColorX}
  \Test{}{}{}{}{}%
  \Test{0.1 0.2 0.3}{[rgb]{.1,.2,.3}}{.1 .2 .3 set-rgb}%
       {/C[.1 .2 .3]}{/C[.1 .2 .3]}%
  \Test{[gray]{0.4}}{[gray]{0.4}}{.4 set-gray}%
       {/C[.4 .4 .4]}{/C[.4]}%
  \Test{[rgb]{0.3,.2,.1}}{[rgb]{0.3,.2,.1}}{.3 .2 .1 set-rgb}%
       {/C[.3 .2 .1]}{/C[.3 .2 .1]}%
  \Test{0.0 1.0 1}{[rgb]{0,1,1}}{0 1 1 set-rgb}%
       {/C[0 1 1]}{/C[0 1 1]}%
  \Test{[gray]1}{[gray]1}{1 set-gray}{/C[1 1 1]}{/C[1]}%
  \Test{red}{red}{1 0 0 set-rgb}{/C[1 0 0]}{/C[1 0 0]}%
  \Test{black}{black}{0 set-gray}{/C[0 0 0]}{/C[0]}%
  \Test{cyan}{cyan}{1 0 0 0 set-cmyk}{/C[0 1 1]}{/C[1 0 0 0]}%
  \Test{[named]{black}}{[named]{black}}{0 0 0 set-rgb}%
       {/C[0 0 0]}{/C[0 0 0]}%
  \Test{[Gray]{9}}{[Gray]{9}}{.6 set-gray}{/C[.6 .6 .6]}{/C[.6]}%
  \Test{[HTML]{0080FF}}{[HTML]{0080FF}}{0 .50195 1 set-rgb}%
       {/C[0 .50195 1]}{/C[0 .50195 1]}%
  \Test{graynine}{graynine}{.9 set-gray}{/C[.9 .9 .9]}{/C[.9]}%
  \Test{GraySix}{GraySix}{.6 set-gray}{/C[.6 .6 .6]}{/C[.6]}%
  \Test{[wave]{500}}{[wave]{500}}{0 1 .49846 set-rgb}%
       {/C[0 1 .49846]}{/C[0 1 .49846]}%
  \TestError[6]{[empty]{}}{}{}{}\NoEmptyModel
  \TestError[7]{[empty]{}}{}{}{}\NoEmptyModel
\end{qstest}
\begin{document}
\end{document}
\endinput
%%
%% End of file `hycolor-test3.tex'.
