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

Side by Side Diff: chrome/browser/google_apis/base_operations_server_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/google_apis/base_operations.h" 5 #include "chrome/browser/google_apis/base_operations.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 virtual void TearDown() OVERRIDE { 59 virtual void TearDown() OVERRIDE {
60 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); 60 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete());
61 request_context_getter_ = NULL; 61 request_context_getter_ = NULL;
62 } 62 }
63 63
64 // Returns a temporary file path suitable for storing the cache file. 64 // Returns a temporary file path suitable for storing the cache file.
65 base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) { 65 base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) {
66 return profile_->GetPath().Append(file_name); 66 return profile_->GetPath().Append(file_name);
67 } 67 }
68 68
69 MessageLoopForUI message_loop_; 69 base::MessageLoopForUI message_loop_;
70 content::TestBrowserThread ui_thread_; 70 content::TestBrowserThread ui_thread_;
71 content::TestBrowserThread file_thread_; 71 content::TestBrowserThread file_thread_;
72 content::TestBrowserThread io_thread_; 72 content::TestBrowserThread io_thread_;
73 test_server::HttpServer test_server_; 73 test_server::HttpServer test_server_;
74 scoped_ptr<TestingProfile> profile_; 74 scoped_ptr<TestingProfile> profile_;
75 OperationRegistry operation_registry_; 75 OperationRegistry operation_registry_;
76 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; 76 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
77 77
78 // The incoming HTTP request is saved so tests can verify the request 78 // The incoming HTTP request is saved so tests can verify the request
79 // parameters like HTTP method (ex. some operations should use DELETE 79 // parameters like HTTP method (ex. some operations should use DELETE
(...skipping 11 matching lines...) Expand all
91 base::Bind(&test_util::RunAndQuit), 91 base::Bind(&test_util::RunAndQuit),
92 test_util::CreateCopyResultCallback(&result_code, &temp_file)), 92 test_util::CreateCopyResultCallback(&result_code, &temp_file)),
93 GetContentCallback(), 93 GetContentCallback(),
94 ProgressCallback(), 94 ProgressCallback(),
95 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), 95 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"),
96 base::FilePath::FromUTF8Unsafe("/dummy/gdata/testfile.txt"), 96 base::FilePath::FromUTF8Unsafe("/dummy/gdata/testfile.txt"),
97 GetTestCachedFilePath( 97 GetTestCachedFilePath(
98 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); 98 base::FilePath::FromUTF8Unsafe("cached_testfile.txt")));
99 operation->Start(kTestAuthToken, kTestUserAgent, 99 operation->Start(kTestAuthToken, kTestUserAgent,
100 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 100 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
101 MessageLoop::current()->Run(); 101 base::MessageLoop::current()->Run();
102 102
103 std::string contents; 103 std::string contents;
104 file_util::ReadFileToString(temp_file, &contents); 104 file_util::ReadFileToString(temp_file, &contents);
105 file_util::Delete(temp_file, false); 105 file_util::Delete(temp_file, false);
106 106
107 EXPECT_EQ(HTTP_SUCCESS, result_code); 107 EXPECT_EQ(HTTP_SUCCESS, result_code);
108 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 108 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
109 EXPECT_EQ("/files/chromeos/gdata/testfile.txt", http_request_.relative_url); 109 EXPECT_EQ("/files/chromeos/gdata/testfile.txt", http_request_.relative_url);
110 110
111 const base::FilePath expected_path = 111 const base::FilePath expected_path =
(...skipping 15 matching lines...) Expand all
127 base::Bind(&test_util::RunAndQuit), 127 base::Bind(&test_util::RunAndQuit),
128 test_util::CreateCopyResultCallback(&result_code, &temp_file)), 128 test_util::CreateCopyResultCallback(&result_code, &temp_file)),
129 GetContentCallback(), 129 GetContentCallback(),
130 ProgressCallback(), 130 ProgressCallback(),
131 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), 131 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"),
132 base::FilePath::FromUTF8Unsafe("/dummy/gdata/no-such-file.txt"), 132 base::FilePath::FromUTF8Unsafe("/dummy/gdata/no-such-file.txt"),
133 GetTestCachedFilePath( 133 GetTestCachedFilePath(
134 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); 134 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt")));
135 operation->Start(kTestAuthToken, kTestUserAgent, 135 operation->Start(kTestAuthToken, kTestUserAgent,
136 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 136 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
137 MessageLoop::current()->Run(); 137 base::MessageLoop::current()->Run();
138 138
139 std::string contents; 139 std::string contents;
140 file_util::ReadFileToString(temp_file, &contents); 140 file_util::ReadFileToString(temp_file, &contents);
141 file_util::Delete(temp_file, false); 141 file_util::Delete(temp_file, false);
142 142
143 EXPECT_EQ(HTTP_NOT_FOUND, result_code); 143 EXPECT_EQ(HTTP_NOT_FOUND, result_code);
144 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 144 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
145 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", 145 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt",
146 http_request_.relative_url); 146 http_request_.relative_url);
147 // Do not verify the not found message. 147 // Do not verify the not found message.
148 } 148 }
149 149
150 } // namespace google_apis 150 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698