Add test for the waitForBytesWritten() method

Change-Id: I4a6767196d205cf1f0715edfb9ea117a2d7fa5c9
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Disable automatic header precompilation for QtSerialPort

There are two source files for this module only. Adding a header
precompilation is more expensive than the benefit.

Change-Id: I27f0756693ec655f56a781f94d14840ce48f71b4
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Refactor unix setBaudRate() error handling

Return QSerialPort::SerialPortError instead of bool

Change-Id: I79d731c1a0178ef0238495d7e9bb3e1b866e82c0
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Move out processing of ResoureError from processIoErrors()

Handling of the ResourceError is moved directly to
_q_completeAsyncCommunication() method.

Reasons:

* The processIoErrors() should handle only the
EV_ERR event.

* The handling of ResourceError in the processIoErrors()
it is the old heritage when the event processing logic
was into the notifiers.

Also the method processIoErrors() is renamed in favor to
handleLineStatusErrors() for readability, according to
documentation on EV_ERR mask:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363479%28v=vs.85%29.aspx

Tested build on Windows 7/8 using Qt4 and then Qt5.

Change-Id: I6dc331933155f1e182b21f40885e47d574c4ed9f
Reviewed-by: Dyami Caliri <dyami@dragonframe.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Don't emit error in destructor of QSerialPort.

QSerialPort::~QSerialPort() calls close() which emits an error if the
port is already closed. This error signal may then call slots of
already (partially) deleted objects.

Task-number: QTBUG-39369
Change-Id: I28bf94564ae120619054c6920779da974dccdad6
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Fix the error message for TimeoutError on Windows

At timeouts from the waitForX() methods are set a wrong
error string. Thing in that the WAIT_TIMEOUT constant is
not a system error, therefore call of GetLastError()
returns a code of a system error which was set by someone
earlier.

Thus, it is necessary to extract text representation of
an error directly from the WAIT_TIMEOUT constant without
relying on GetLastError().

Tested on Windows 7/8 using Qt4 and then Qt5.

Change-Id: Id7fdc71c1b64c39eed658148bb1b66ac8806f119
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Dyami Caliri <dyami@dragonframe.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Improve the setStandardBaudRate() on Linux

* The ASYNC_SPD_CUST flag shall be cleared only if it was earlier
set; otherwise it is not necessary to touch of the serial struct.

* Seems, that is more reasonable to return an error code when
writing back of the serial struct is failed. In this case it is
an error, because we know that serial struct is supported, since
we got it successfully earlier.

Tested build on Archlinux 64 bit using Qt4 and then Qt5.
Tested build on Android x86 using Qt5.

Change-Id: I54ca4772dc770dabac5e3555e6cb42ecc23255a4
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Fix waitForReadyRead() on windows

The commit 2360c401ae2012ed1b5a2b470a088cbbdb0d7f27 introduced an
regression into waitForReadyRead(). Before this commit each read
transaction was started again until the zero number of bytes will
returns from FIFO. When FIFO is empty, all data has been read, and
only then the waitForReadyRead() return true. I.e. condition
"qint64(readBuffer.size()) != currentReadBufferSize" does not mean
that reading is finished.

But after that commit this condition is incorrect, because now each
read operation started once and can not return zero bytes (in case
the number of read bytes less than ReadChunkSize). Thus it led to
returning of TimeoutError error.

Now, this issue has been fixed. Also is added the set of auto-tests
to testing of the waitForReadyRead() method.

Tested on Windows 7/8 using Qt5 and then Qt4.

Task-number: QTBUG-39314
Change-Id: I8abbf986c2a1cc77af634ddbc1747fb46f416a39
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>