diff options
Diffstat (limited to 'ceee/ie/testing/ie_unittest_main.cc')
-rw-r--r-- | ceee/ie/testing/ie_unittest_main.cc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/ceee/ie/testing/ie_unittest_main.cc b/ceee/ie/testing/ie_unittest_main.cc new file mode 100644 index 0000000..2317472 --- /dev/null +++ b/ceee/ie/testing/ie_unittest_main.cc @@ -0,0 +1,77 @@ +// Copyright (c) 2010 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. +// +// Main function for common unittests. +#include <atlbase.h> +#include <atlcom.h> +#include "base/at_exit.h" +#include "base/command_line.h" +#include "base/logging.h" +#include "ceee/testing/utils/gflag_utils.h" +#include "chrome/common/url_constants.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "toolband.h" // NOLINT + +// Stub for unittesting. +namespace ceee_module_util { + +LONG LockModule() { + return 0; +} +LONG UnlockModule() { + return 0; +} +void Lock() { +} +void Unlock() { +} +void AddRefModuleWorkerThread() { +} +void ReleaseModuleWorkerThread() { +} + +// Fires an event to the broker, so that the call can be made with an +// instance of a broker proxy that was CoCreated in the worker thread. +void FireEventToBroker(const std::string& event_name, + const std::string& event_args) { + // Must get some work done so that the function can be mocked. + // Otherwise, it would be too short to be side stepped... + if (event_name == event_args) { + CHECK(event_name == event_args); + } else { + CHECK(event_name != event_args); + } +} + +} // namespace ceee_module_util + + +// We're testing ATL code that requires a module object. +class ObligatoryModule: public CAtlDllModuleT<ObligatoryModule> { + public: + DECLARE_LIBID(LIBID_ToolbandLib); +}; + +ObligatoryModule g_obligatory_atl_module; + +// Run these tests under page heap. +const DWORD kGFlags = FLG_USER_STACK_TRACE_DB | FLG_HEAP_PAGE_ALLOCS; + +int main(int argc, char **argv) { + // Disabled, bb2560934. + // if (!IsDebuggerPresent()) + // testing::RelaunchWithGFlags(kTestGFlags); + + base::AtExitManager at_exit; + CommandLine::Init(argc, argv); + + // Needs to be called before we can use GURL. + chrome::RegisterChromeSchemes(); + + testing::InitGoogleMock(&argc, argv); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} |