Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/local_discovery/pwg_raster_converter.h" 18 #include "chrome/browser/local_discovery/pwg_raster_converter.h"
19 #include "chrome/browser/ui/webui/print_preview/extension_printer_handler.h" 19 #include "chrome/browser/ui/webui/print_preview/extension_printer_handler.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "extensions/browser/api/printer_provider/printer_provider_api.h" 22 #include "extensions/browser/api/printer_provider/printer_provider_api.h"
22 #include "extensions/browser/api/printer_provider/printer_provider_api_factory.h " 23 #include "extensions/browser/api/printer_provider/printer_provider_api_factory.h "
23 #include "extensions/browser/api/printer_provider/printer_provider_print_job.h" 24 #include "extensions/browser/api/printer_provider/printer_provider_print_job.h"
24 #include "printing/pdf_render_settings.h" 25 #include "printing/pdf_render_settings.h"
25 #include "printing/pwg_raster_settings.h" 26 #include "printing/pwg_raster_settings.h"
26 #include "printing/units.h" 27 #include "printing/units.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/gfx/geometry/size.h" 29 #include "ui/gfx/geometry/size.h"
29 30
30 using extensions::PrinterProviderAPI; 31 using extensions::PrinterProviderAPI;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ~ExtensionPrinterHandlerTest() override = default; 364 ~ExtensionPrinterHandlerTest() override = default;
364 365
365 void SetUp() override { 366 void SetUp() override {
366 TestingProfile::Builder profile_builder; 367 TestingProfile::Builder profile_builder;
367 profile_builder.AddTestingFactory( 368 profile_builder.AddTestingFactory(
368 extensions::PrinterProviderAPIFactory::GetInstance(), 369 extensions::PrinterProviderAPIFactory::GetInstance(),
369 &BuildTestingPrinterProviderAPI); 370 &BuildTestingPrinterProviderAPI);
370 profile_ = profile_builder.Build(); 371 profile_ = profile_builder.Build();
371 372
372 extension_printer_handler_.reset(new ExtensionPrinterHandler( 373 extension_printer_handler_.reset(new ExtensionPrinterHandler(
373 profile_.get(), message_loop_.task_runner())); 374 profile_.get(), base::MessageLoop::current()->task_runner()));
374 375
375 pwg_raster_converter_ = new FakePWGRasterConverter(); 376 pwg_raster_converter_ = new FakePWGRasterConverter();
376 extension_printer_handler_->SetPwgRasterConverterForTesting( 377 extension_printer_handler_->SetPwgRasterConverterForTesting(
377 scoped_ptr<PWGRasterConverter>(pwg_raster_converter_)); 378 scoped_ptr<PWGRasterConverter>(pwg_raster_converter_));
378 } 379 }
379 380
380 protected: 381 protected:
381 FakePrinterProviderAPI* GetPrinterProviderAPI() { 382 FakePrinterProviderAPI* GetPrinterProviderAPI() {
382 return static_cast<FakePrinterProviderAPI*>( 383 return static_cast<FakePrinterProviderAPI*>(
383 extensions::PrinterProviderAPIFactory::GetInstance() 384 extensions::PrinterProviderAPIFactory::GetInstance()
384 ->GetForBrowserContext(profile_.get())); 385 ->GetForBrowserContext(profile_.get()));
385 } 386 }
386 387
387 scoped_ptr<ExtensionPrinterHandler> extension_printer_handler_; 388 scoped_ptr<ExtensionPrinterHandler> extension_printer_handler_;
388 389
389 FakePWGRasterConverter* pwg_raster_converter_; 390 FakePWGRasterConverter* pwg_raster_converter_;
390 391
391 private: 392 private:
392 base::MessageLoop message_loop_; 393 content::TestBrowserThreadBundle thread_bundle_;
393 394
394 scoped_ptr<TestingProfile> profile_; 395 scoped_ptr<TestingProfile> profile_;
395 396
396 DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandlerTest); 397 DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandlerTest);
397 }; 398 };
398 399
399 TEST_F(ExtensionPrinterHandlerTest, GetPrinters) { 400 TEST_F(ExtensionPrinterHandlerTest, GetPrinters) {
400 size_t call_count = 0; 401 size_t call_count = 0;
401 scoped_ptr<base::ListValue> printers; 402 scoped_ptr<base::ListValue> printers;
402 bool is_done = false; 403 bool is_done = false;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 extension_printer_handler_->StartPrint( 787 extension_printer_handler_->StartPrint(
787 kPrinterId, kPWGRasterOnlyPrinterSimpleDescription, title, 788 kPrinterId, kPWGRasterOnlyPrinterSimpleDescription, title,
788 kEmptyPrintTicket, gfx::Size(100, 100), print_data, 789 kEmptyPrintTicket, gfx::Size(100, 100), print_data,
789 base::Bind(&RecordPrintResult, &call_count, &success, &status)); 790 base::Bind(&RecordPrintResult, &call_count, &success, &status));
790 791
791 EXPECT_EQ(1u, call_count); 792 EXPECT_EQ(1u, call_count);
792 793
793 EXPECT_FALSE(success); 794 EXPECT_FALSE(success);
794 EXPECT_EQ("INVALID_DATA", status); 795 EXPECT_EQ("INVALID_DATA", status);
795 } 796 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc ('k') | chromeos/dbus/services/service_provider_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698