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

Unified Diff: chrome/browser/net/file_reader_unittest.cc

Issue 256022: Loads local resources from current locale subtree if available, if not it fal... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/file_reader.cc ('k') | chrome/browser/views/browser_actions_container.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/file_reader_unittest.cc
===================================================================
--- chrome/browser/net/file_reader_unittest.cc (revision 28272)
+++ chrome/browser/net/file_reader_unittest.cc (working copy)
@@ -1,92 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/file_util.h"
-#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/net/file_reader.h"
-#include "chrome/common/chrome_paths.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class FileReaderTest : public testing::Test {
- public:
- FileReaderTest() : file_thread_(ChromeThread::FILE) {
- file_thread_.Start();
- }
- private:
- MessageLoop message_loop_;
- ChromeThread file_thread_;
-};
-
-class Receiver {
- public:
- Receiver() : succeeded_(false) {
- }
-
- FileReader::Callback* NewCallback() {
- return ::NewCallback(this, &Receiver::DidReadFile);
- }
-
- bool succeeded() const { return succeeded_; }
- const std::string& data() const { return data_; }
-
- private:
- void DidReadFile(bool success, const std::string& data) {
- succeeded_ = success;
- data_ = data;
- MessageLoop::current()->Quit();
- }
-
- bool succeeded_;
- std::string data_;
-};
-
-void RunBasicTest(const char* filename) {
- FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- path = path.AppendASCII(filename);
-
- std::string file_contents;
- bool file_exists = file_util::ReadFileToString(path, &file_contents);
-
- Receiver receiver;
-
- scoped_refptr<FileReader> file_reader(
- new FileReader(path, receiver.NewCallback()));
- file_reader->Start();
-
- MessageLoop::current()->Run();
-
- EXPECT_EQ(file_exists, receiver.succeeded());
- EXPECT_EQ(file_contents, receiver.data());
-}
-
-TEST_F(FileReaderTest, SmallFile) {
- RunBasicTest("title1.html");
-}
-
-TEST_F(FileReaderTest, BiggerFile) {
- RunBasicTest("download-test1.lib");
-}
-
-TEST_F(FileReaderTest, NonExistantFile) {
- FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- path = path.AppendASCII("file_that_does_not_exist");
-
- Receiver receiver;
-
- scoped_refptr<FileReader> file_reader(
- new FileReader(path, receiver.NewCallback()));
- file_reader->Start();
-
- MessageLoop::current()->Run();
-
- EXPECT_FALSE(receiver.succeeded());
-}
-
-} // namespace
« no previous file with comments | « chrome/browser/net/file_reader.cc ('k') | chrome/browser/views/browser_actions_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698