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

Side by Side Diff: chrome/test/ui_test_utils.cc

Issue 6042009: Added WARN_UNUSED_RESULT to ScopedTempDir methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace fix Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/test/ui_test_utils.h" 5 #include "chrome/test/ui_test_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 std::string newpath(oldpath); 700 std::string newpath(oldpath);
701 newpath.append(":"); 701 newpath.append(":");
702 newpath.append(dir.value()); 702 newpath.append(dir.value());
703 setenv(kPythonPath, newpath.c_str(), 1); 703 setenv(kPythonPath, newpath.c_str(), 1);
704 } 704 }
705 #endif 705 #endif
706 } 706 }
707 707
708 } // anonymous namespace 708 } // anonymous namespace
709 709
710 TestWebSocketServer::TestWebSocketServer(const FilePath& root_directory) { 710 TestWebSocketServer::TestWebSocketServer()
711 : started_(false) {
Paweł Hajdan Jr. 2011/01/11 13:01:10 nit: Can we fit it in the previous line?
cbentzel 2011/01/11 19:56:38 Done.
712 }
713
714 bool TestWebSocketServer::Start(const FilePath& root_directory) {
715 if (started_)
716 return true;
711 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); 717 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
712 cmd_line->AppendSwitchASCII("server", "start"); 718 cmd_line->AppendSwitchASCII("server", "start");
713 cmd_line->AppendSwitch("chromium"); 719 cmd_line->AppendSwitch("chromium");
714 cmd_line->AppendSwitch("register_cygwin"); 720 cmd_line->AppendSwitch("register_cygwin");
715 cmd_line->AppendSwitchPath("root", root_directory); 721 cmd_line->AppendSwitchPath("root", root_directory);
716 temp_dir_.CreateUniqueTempDir(); 722 if (!temp_dir_.CreateUniqueTempDir())
Paweł Hajdan Jr. 2011/01/11 13:01:10 LOG messages would be useful for all error cases h
cbentzel 2011/01/11 19:56:38 Done.
723 return false;
717 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); 724 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid");
718 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); 725 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_);
719 SetPythonPath(); 726 SetPythonPath();
720 base::LaunchApp(*cmd_line.get(), true, false, NULL); 727 if (!base::LaunchApp(*cmd_line.get(), true, false, NULL))
Paweł Hajdan Jr. 2011/01/11 13:01:10 nit: maybe just started_ = LaunchApp; return start
cbentzel 2011/01/11 19:56:38 I added a LOG in failure case, so kept the old ver
728 return false;
729 started_ = true;
730 return true;
721 } 731 }
722 732
723 CommandLine* TestWebSocketServer::CreatePythonCommandLine() { 733 CommandLine* TestWebSocketServer::CreatePythonCommandLine() {
724 return new CommandLine(FilePath(FILE_PATH_LITERAL("python"))); 734 return new CommandLine(FilePath(FILE_PATH_LITERAL("python")));
725 } 735 }
726 736
727 void TestWebSocketServer::SetPythonPath() { 737 void TestWebSocketServer::SetPythonPath() {
728 FilePath scripts_path; 738 FilePath scripts_path;
729 PathService::Get(base::DIR_SOURCE_ROOT, &scripts_path); 739 PathService::Get(base::DIR_SOURCE_ROOT, &scripts_path);
730 740
(...skipping 16 matching lines...) Expand all
747 script_path = script_path.AppendASCII("Tools"); 757 script_path = script_path.AppendASCII("Tools");
748 script_path = script_path.AppendASCII("Scripts"); 758 script_path = script_path.AppendASCII("Scripts");
749 script_path = script_path.AppendASCII("new-run-webkit-websocketserver"); 759 script_path = script_path.AppendASCII("new-run-webkit-websocketserver");
750 760
751 CommandLine* cmd_line = CreatePythonCommandLine(); 761 CommandLine* cmd_line = CreatePythonCommandLine();
752 cmd_line->AppendArgPath(script_path); 762 cmd_line->AppendArgPath(script_path);
753 return cmd_line; 763 return cmd_line;
754 } 764 }
755 765
756 TestWebSocketServer::~TestWebSocketServer() { 766 TestWebSocketServer::~TestWebSocketServer() {
767 if (!started_)
768 return;
757 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); 769 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
758 cmd_line->AppendSwitchASCII("server", "stop"); 770 cmd_line->AppendSwitchASCII("server", "stop");
759 cmd_line->AppendSwitch("chromium"); 771 cmd_line->AppendSwitch("chromium");
760 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); 772 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_);
761 base::LaunchApp(*cmd_line.get(), true, false, NULL); 773 base::LaunchApp(*cmd_line.get(), true, false, NULL);
762 } 774 }
763 775
764 WindowedNotificationObserver::WindowedNotificationObserver( 776 WindowedNotificationObserver::WindowedNotificationObserver(
765 NotificationType notification_type, 777 NotificationType notification_type,
766 const NotificationSource& source) 778 const NotificationSource& source)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 924 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
913 } 925 }
914 926
915 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 927 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
916 DCHECK(bitmap); 928 DCHECK(bitmap);
917 SnapshotTaker taker; 929 SnapshotTaker taker;
918 return taker.TakeEntirePageSnapshot(rvh, bitmap); 930 return taker.TakeEntirePageSnapshot(rvh, bitmap);
919 } 931 }
920 932
921 } // namespace ui_test_utils 933 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698