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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_documents_service_browsertest.cc

Issue 10822030: Move ui_test_utils::RunMessageLoop to test_utils so that it can be reused by content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" 10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 IN_PROC_BROWSER_TEST_F(GDataTest, Download) { 74 IN_PROC_BROWSER_TEST_F(GDataTest, Download) {
75 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; 75 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR;
76 std::string contents; 76 std::string contents;
77 service_->DownloadFile( 77 service_->DownloadFile(
78 FilePath("/dummy/gdata/testfile.txt"), 78 FilePath("/dummy/gdata/testfile.txt"),
79 GetTestCachedFilePath(FilePath("cached_testfile.txt")), 79 GetTestCachedFilePath(FilePath("cached_testfile.txt")),
80 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), 80 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"),
81 base::Bind(&TestDownloadCallback, &result, &contents), 81 base::Bind(&TestDownloadCallback, &result, &contents),
82 gdata::GetDownloadDataCallback()); 82 gdata::GetDownloadDataCallback());
83 ui_test_utils::RunMessageLoop(); 83 content::RunMessageLoop();
84 84
85 EXPECT_EQ(gdata::HTTP_SUCCESS, result); 85 EXPECT_EQ(gdata::HTTP_SUCCESS, result);
86 FilePath expected_filepath = gdata_test_server_.document_root().Append( 86 FilePath expected_filepath = gdata_test_server_.document_root().Append(
87 FilePath(FILE_PATH_LITERAL("chromeos/gdata/testfile.txt"))); 87 FilePath(FILE_PATH_LITERAL("chromeos/gdata/testfile.txt")));
88 std::string expected_contents; 88 std::string expected_contents;
89 file_util::ReadFileToString(expected_filepath, &expected_contents); 89 file_util::ReadFileToString(expected_filepath, &expected_contents);
90 EXPECT_EQ(expected_contents, contents); 90 EXPECT_EQ(expected_contents, contents);
91 } 91 }
92 92
93 IN_PROC_BROWSER_TEST_F(GDataTest, NonExistingDownload) { 93 IN_PROC_BROWSER_TEST_F(GDataTest, NonExistingDownload) {
94 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; 94 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR;
95 std::string dummy_contents; 95 std::string dummy_contents;
96 service_->DownloadFile( 96 service_->DownloadFile(
97 FilePath("/dummy/gdata/no-such-file.txt"), 97 FilePath("/dummy/gdata/no-such-file.txt"),
98 GetTestCachedFilePath(FilePath("cache_no-such-file.txt")), 98 GetTestCachedFilePath(FilePath("cache_no-such-file.txt")),
99 gdata_test_server_.GetURL("files/chromeos/gdata/no-such-file.txt"), 99 gdata_test_server_.GetURL("files/chromeos/gdata/no-such-file.txt"),
100 base::Bind(&TestDownloadCallback, &result, &dummy_contents), 100 base::Bind(&TestDownloadCallback, &result, &dummy_contents),
101 gdata::GetDownloadDataCallback()); 101 gdata::GetDownloadDataCallback());
102 ui_test_utils::RunMessageLoop(); 102 content::RunMessageLoop();
103 103
104 EXPECT_EQ(gdata::HTTP_NOT_FOUND, result); 104 EXPECT_EQ(gdata::HTTP_NOT_FOUND, result);
105 // Do not verify the not found message. 105 // Do not verify the not found message.
106 } 106 }
107 107
108 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) { 108 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) {
109 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; 109 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR;
110 base::Value* result_data = NULL; 110 base::Value* result_data = NULL;
111 service_->GetDocuments( 111 service_->GetDocuments(
112 gdata_test_server_.GetURL("files/chromeos/gdata/root_feed.json"), 112 gdata_test_server_.GetURL("files/chromeos/gdata/root_feed.json"),
113 0, // start_changestamp 113 0, // start_changestamp
114 std::string(), // search string 114 std::string(), // search string
115 std::string(), // directory resource ID 115 std::string(), // directory resource ID
116 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); 116 base::Bind(&TestGetDocumentsCallback, &result, &result_data));
117 ui_test_utils::RunMessageLoop(); 117 content::RunMessageLoop();
118 118
119 EXPECT_EQ(gdata::HTTP_SUCCESS, result); 119 EXPECT_EQ(gdata::HTTP_SUCCESS, result);
120 ASSERT_TRUE(result_data); 120 ASSERT_TRUE(result_data);
121 FilePath expected_filepath = gdata_test_server_.document_root().Append( 121 FilePath expected_filepath = gdata_test_server_.document_root().Append(
122 FilePath(FILE_PATH_LITERAL("chromeos/gdata/root_feed.json"))); 122 FilePath(FILE_PATH_LITERAL("chromeos/gdata/root_feed.json")));
123 std::string expected_contents; 123 std::string expected_contents;
124 file_util::ReadFileToString(expected_filepath, &expected_contents); 124 file_util::ReadFileToString(expected_filepath, &expected_contents);
125 scoped_ptr<base::Value> expected_data( 125 scoped_ptr<base::Value> expected_data(
126 base::JSONReader::Read(expected_contents)); 126 base::JSONReader::Read(expected_contents));
127 EXPECT_TRUE(base::Value::Equals(expected_data.get(), result_data)); 127 EXPECT_TRUE(base::Value::Equals(expected_data.get(), result_data));
128 delete result_data; 128 delete result_data;
129 } 129 }
130 130
131 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocumentsFailure) { 131 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocumentsFailure) {
132 // testfile.txt exists but the response is not JSON, so it should 132 // testfile.txt exists but the response is not JSON, so it should
133 // emit a parse error instead. 133 // emit a parse error instead.
134 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; 134 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR;
135 base::Value* result_data = NULL; 135 base::Value* result_data = NULL;
136 service_->GetDocuments( 136 service_->GetDocuments(
137 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), 137 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"),
138 0, // start_changestamp 138 0, // start_changestamp
139 std::string(), // search string 139 std::string(), // search string
140 std::string(), // directory resource ID 140 std::string(), // directory resource ID
141 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); 141 base::Bind(&TestGetDocumentsCallback, &result, &result_data));
142 ui_test_utils::RunMessageLoop(); 142 content::RunMessageLoop();
143 143
144 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); 144 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result);
145 EXPECT_FALSE(result_data); 145 EXPECT_FALSE(result_data);
146 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698