Commit 13b94c9b authored by thakis@chromium.org's avatar thakis@chromium.org

Revert 148856 (broke mac, asan, linux cros bots)

cc1plus: warnings being treated as errors
./chrome/browser/extensions/api/api_resource_manager.h: In member function 'void extensions::TestExtensionSystem::CreateSocketManager()':
./chrome/browser/extensions/api/api_resource_manager.h:28:error: 'id' is used uninitialized in this function
chrome/browser/extensions/test_extension_system.cc:55: note: 'id' was declared here



/b/build/slave/cr-mac-rel/build/src/chrome/browser/extensions/test_extension_system.cc:56:3:error: variable 'id' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
  DCHECK(BrowserThread::GetCurrentThreadIdentifier(&id));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../base/logging.h:706:35: note: expanded from macro 'DCHECK'
  LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition))   \
                                  ^
../base/logging.h:670:3: note: expanded from macro 'DCHECK_IS_ON'
  ((::logging::g_dcheck_state ==                                        \
  ^
../base/logging.h:362:5: note: expanded from macro 'LAZY_STREAM'
  !(condition) ? (void) 0 : ::logging::LogMessageVoidify() & (stream)
    ^~~~~~~~~
/b/build/slave/cr-mac-rel/build/src/chrome/browser/extensions/test_extension_system.cc:57:56: note: uninitialized use occurs here
  socket_manager_.reset(new ApiResourceManager<Socket>(id));
                                                       ^~
/b/build/slave/cr-mac-rel/build/src/chrome/browser/extensions/test_extension_system.cc:56:3: note: remove the '&&' if its condition is always true
  DCHECK(BrowserThread::GetCurrentThreadIdentifier(&id));
  ^
../base/logging.h:706:35: note: expanded from macro 'DCHECK'
  LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition))   \
                                  ^
../base/logging.h:670:3: note: expanded from macro 'DCHECK_IS_ON'
  ((::logging::g_dcheck_state ==                                        \
  ^
../base/logging.h:362:5: note: expanded from macro 'LAZY_STREAM'
  !(condition) ? (void) 0 : ::logging::LogMessageVoidify() & (stream)
    ^
/b/build/slave/cr-mac-rel/build/src/chrome/browser/extensions/test_extension_system.cc:55:3: note: variable 'id' is declared here
  BrowserThread::ID id;
  ^
1 error generated.


- Improve unit testing of socket API.

Add socket_api_unittest.cc, which calls Socket API functions directly.
This skips the whole browser_tests setup that is relatively slow and
expensive. The current test merely validates the socket-type argument
handling, but the next phase will simulate blocking socket operations.

BUG=112902
TEST=see above


Review URL: https://chromiumcodereview.appspot.com/10795052

TBR=miket@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10830061

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148859 0039d316-1c4b-4281-b951-d872f2087c98
parent 8d425e44
......@@ -42,10 +42,6 @@ SocketAsyncApiFunction::~SocketAsyncApiFunction() {
bool SocketAsyncApiFunction::PrePrepare() {
manager_ = ExtensionSystem::Get(profile())->socket_manager();
DCHECK(manager_) << "There is no socket manager. "
"If this assertion is failing during a test, then it is likely that "
"TestExtensionSystem is failing to provide an instance of "
"ApiResourceManager<Socket>.";
return manager_ != NULL;
}
......
// Copyright (c) 2012 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/values.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/extensions/api/socket/socket_api.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace utils = extension_function_test_utils;
namespace extensions {
class SocketUnitTest : public BrowserWithTestWindowTest {
public:
virtual void SetUp() {
BrowserWithTestWindowTest::SetUp();
TestExtensionSystem* system = static_cast<TestExtensionSystem*>(
ExtensionSystem::Get(browser()->profile()));
system->CreateSocketManager();
extension_ = utils::CreateEmptyExtensionWithLocation(
extensions::Extension::LOAD);
}
base::Value* RunFunctionWithExtension(
UIThreadExtensionFunction* function, const std::string& args) {
function->set_extension(extension_.get());
return utils::RunFunctionAndReturnSingleResult(function, args, browser());
}
base::DictionaryValue* RunFunctionAndReturnDict(
UIThreadExtensionFunction* function, const std::string& args) {
base::Value* result = RunFunctionWithExtension(function, args);
return result ? utils::ToDictionary(result) : NULL;
}
base::ListValue* RunFunctionAndReturnList(
UIThreadExtensionFunction* function, const std::string& args) {
base::Value* result = RunFunctionWithExtension(function, args);
return result ? utils::ToList(result) : NULL;
}
void RunFunction(UIThreadExtensionFunction* function,
const std::string& args) {
scoped_ptr<base::Value> result(RunFunctionWithExtension(function, args));
}
std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
const std::string& args) {
function->set_extension(extension_.get());
return utils::RunFunctionAndReturnError(function, args, browser());
}
protected:
scoped_refptr<extensions::Extension> extension_;
};
TEST_F(SocketUnitTest, Create) {
// TODO(miket): enable this test. This will require teaching
// SocketCreateFunction to do its work on a thread other than IO. Getting
// this CL landed was hard enough already, so we're going to save this work
// for another day.
if (false) {
scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDict(
new SocketCreateFunction(), "[\"tcp\"]"));
ASSERT_TRUE(result.get());
}
{
std::string error = RunFunctionAndReturnError(
new SocketCreateFunction(), "[\"nonexistent-socket-type\"]");
ASSERT_FALSE(error.empty()) << "Expected error. Got nothing instead.";
}
}
} // namespace extensions
......@@ -19,9 +19,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/value_store/testing_value_store.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
namespace extensions {
......@@ -46,17 +43,6 @@ void TestExtensionSystem::CreateAlarmManager(
alarm_manager_.reset(new AlarmManager(profile_, now));
}
void TestExtensionSystem::CreateSocketManager() {
// Note that we're intentionally creating the socket manager on the wrong
// thread (not the IO thread). This is because we don't want to presume or
// require that there be an IO thread in a lightweight test context. If we do
// need thread-specific behavior someday, we'll probably need something like
// CreateSocketManagerOnThreadForTesting(thread_id). But not today.
BrowserThread::ID id;
DCHECK(BrowserThread::GetCurrentThreadIdentifier(&id));
socket_manager_.reset(new ApiResourceManager<Socket>(id));
}
ExtensionService* TestExtensionSystem::CreateExtensionService(
const CommandLine* command_line,
const FilePath& install_directory,
......@@ -152,7 +138,7 @@ TestExtensionSystem::serial_connection_manager() {
}
ApiResourceManager<Socket>*TestExtensionSystem::socket_manager() {
return socket_manager_.get();
return NULL;
}
ApiResourceManager<UsbDeviceResource>*
......
......@@ -41,8 +41,6 @@ class TestExtensionSystem : public ExtensionSystem {
// Creates an AlarmManager. Will be NULL otherwise.
void CreateAlarmManager(base::Time (*now)());
void CreateSocketManager();
virtual void Init(bool extensions_enabled) OVERRIDE {}
void SetExtensionService(ExtensionService* service);
virtual ExtensionService* extension_service() OVERRIDE;
......@@ -78,7 +76,6 @@ class TestExtensionSystem : public ExtensionSystem {
scoped_ptr<ExtensionProcessManager> extension_process_manager_;
scoped_ptr<AlarmManager> alarm_manager_;
scoped_refptr<ExtensionInfoMap> info_map_;
scoped_ptr<ApiResourceManager<Socket> > socket_manager_;
};
} // namespace extensions
......
......@@ -1206,19 +1206,18 @@
'browser/extensions/api/cookies/cookies_unittest.cc',
'browser/extensions/api/declarative/initializing_rules_registry_unittest.cc',
'browser/extensions/api/declarative/rules_registry_service_unittest.cc',
'browser/extensions/api/discovery/discovery_api_unittest.cc',
'browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc',
'browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc',
'browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc',
'browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc',
'browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc',
'browser/extensions/api/discovery/discovery_api_unittest.cc',
'browser/extensions/api/extension_action/extension_browser_actions_api_unittest.cc',
'browser/extensions/api/identity/web_auth_flow_unittest.cc',
'browser/extensions/api/omnibox/omnibox_unittest.cc',
'browser/extensions/api/permissions/permissions_api_helpers_unittest.cc',
'browser/extensions/api/proxy/proxy_api_helpers_unittest.cc',
'browser/extensions/api/serial/serial_port_enumerator_unittest.cc',
'browser/extensions/api/socket/socket_api_unittest.cc',
'browser/extensions/api/socket/tcp_socket_unittest.cc',
'browser/extensions/api/web_navigation/frame_navigation_state_unittest.cc',
'browser/extensions/api/web_request/web_request_api_unittest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment