| Index: printing/emf_win_unittest.cc
|
| diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc
|
| index 4312b2ca7c389549ab40b3626f1e2a6eff086edd..080fea8243049f3006c2fbe997758219866699f5 100644
|
| --- a/printing/emf_win_unittest.cc
|
| +++ b/printing/emf_win_unittest.cc
|
| @@ -15,6 +15,7 @@
|
| #include "base/scoped_ptr.h"
|
| #include "base/scoped_temp_dir.h"
|
| #include "base/win/scoped_hdc.h"
|
| +#include "printing/metafile_factory.h"
|
| #include "printing/printing_context.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -195,3 +196,31 @@ TEST(EmfTest, FileBackedDC) {
|
| emf.CloseEmf();
|
| }
|
|
|
| +TEST(EmfTest, DCFactory) {
|
| + // Simplest use case.
|
| + scoped_ptr<printing::NativeMetafile> emf_ptr(
|
| + printing::MetafileFactory::GetMetafile());
|
| + RECT rect = {100, 100, 200, 200};
|
| + HDC hdc = CreateCompatibleDC(NULL);
|
| + EXPECT_TRUE(hdc != NULL);
|
| + EXPECT_TRUE(emf_ptr->CreateDc(hdc, &rect));
|
| + EXPECT_TRUE(emf_ptr->hdc() != NULL);
|
| + // In theory, you'd use the HDC with GDI functions here.
|
| + EXPECT_TRUE(emf_ptr->CloseDc());
|
| + uint32 size = emf_ptr->GetDataSize();
|
| + EXPECT_EQ(size, EMF_HEADER_SIZE);
|
| + std::vector<BYTE> data;
|
| + EXPECT_TRUE(emf_ptr->GetData(&data));
|
| + EXPECT_EQ(data.size(), size);
|
| + emf_ptr->CloseEmf();
|
| + EXPECT_TRUE(DeleteDC(hdc));
|
| +
|
| + // Playback the data.
|
| + hdc = CreateCompatibleDC(NULL);
|
| + EXPECT_TRUE(hdc);
|
| + EXPECT_TRUE(emf_ptr->Init(&data.front(), size));
|
| + RECT output_rect = {0, 0, 10, 10};
|
| + EXPECT_TRUE(emf_ptr->Playback(hdc, &output_rect));
|
| + EXPECT_TRUE(DeleteDC(hdc));
|
| +}
|
| +
|
|
|