diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 06:48:32 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 06:48:32 +0000 |
commit | 109763bb929004fefa409c342d1c14a78bfe126f (patch) | |
tree | 0614c618674684955caa470ee49d26e05e7dc3e1 /chrome | |
parent | 457764525fd9a27612d7c8bc9d77ae0646db1a56 (diff) | |
download | chromium_src-109763bb929004fefa409c342d1c14a78bfe126f.zip chromium_src-109763bb929004fefa409c342d1c14a78bfe126f.tar.gz chromium_src-109763bb929004fefa409c342d1c14a78bfe126f.tar.bz2 |
Made sync code build and pass unit tests on OS X.
Major changes:
- Moved sync_setup_{flow,wizard} to sync directory.
- Made browser_with_test_window_test compile on non-Windows platform.
- Moved localized contents font util functions to app/.
BUG=23073
TEST=trybot
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=29253
Review URL: http://codereview.chromium.org/279004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
17 files changed, 84 insertions, 62 deletions
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index a83fbbd..f417166 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -31,7 +31,7 @@ class Rect; // BrowserWindow interface // An interface implemented by the "view" of the Browser window. // -// NOTE: All getters except GetTabStrip() may return NULL. +// NOTE: All getters may return NULL. class BrowserWindow { public: // Show the window, or activates it if it's already visible. diff --git a/chrome/browser/sync/engine/syncer.cc b/chrome/browser/sync/engine/syncer.cc index 9274edf..de8b1b2 100644 --- a/chrome/browser/sync/engine/syncer.cc +++ b/chrome/browser/sync/engine/syncer.cc @@ -118,7 +118,7 @@ void Syncer::SyncShare(SyncerSession* session, // Reset silenced_until_, it is the callers responsibility to honor throttles. silenced_until_ = session->silenced_until(); - SyncerStep next_step; + SyncerStep next_step = current_step; while (!ExitRequested()) { switch (current_step) { case SYNCER_BEGIN: diff --git a/chrome/browser/sync/engine/syncer_thread.cc b/chrome/browser/sync/engine/syncer_thread.cc index 073b5ea..0861940 100644 --- a/chrome/browser/sync/engine/syncer_thread.cc +++ b/chrome/browser/sync/engine/syncer_thread.cc @@ -75,7 +75,7 @@ int UserIdleTime() { } int64 idle_time; // in nanoseconds - Boolean success; + Boolean success = false; if (CFGetTypeID(object) == CFNumberGetTypeID()) { success = CFNumberGetValue((CFNumberRef)object, kCFNumberSInt64Type, diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index fab7ea5..9eedbef 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -20,7 +20,7 @@ #include "chrome/browser/sync/glue/change_processor.h" #include "chrome/browser/sync/glue/model_associator.h" #include "chrome/browser/sync/glue/sync_backend_host.h" -#include "chrome/browser/views/sync/sync_setup_wizard.h" +#include "chrome/browser/sync/sync_setup_wizard.h" #include "chrome/common/notification_registrar.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/views/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 01a5728..2784572 100644 --- a/chrome/browser/views/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -4,13 +4,15 @@ #ifdef CHROME_PERSONALIZATION -#include "chrome/browser/views/sync/sync_setup_flow.h" +#include "chrome/browser/sync/sync_setup_flow.h" #include "app/gfx/font.h" +#include "app/gfx/font_util.h" #include "base/histogram.h" #include "base/json_reader.h" #include "base/json_writer.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -20,7 +22,6 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "grit/locale_settings.h" -#include "views/window/window.h" // XPath expression for finding specific iframes. static const wchar_t* kLoginIFrameXPath = L"//iframe[@id='login']"; @@ -156,7 +157,7 @@ void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { prefs->GetString(prefs::kWebKitSansSerifFontFamily), prefs->GetInteger(prefs::kWebKitDefaultFontSize)); - gfx::Size s = views::Window::GetLocalizedContentsSizeForFont( + gfx::Size s = gfx::GetLocalizedContentsSizeForFont( IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, approximate_web_font); @@ -264,10 +265,12 @@ void SyncSetupFlow::Advance(SyncSetupWizard::State advance_state) { flow_handler_->ShowMergeAndSyncError(); break; case SyncSetupWizard::DONE_FIRST_TIME: - flow_handler_->ShowFirstTimeDone(service_->GetAuthenticatedUsername()); + flow_handler_->ShowFirstTimeDone( + UTF16ToWide(service_->GetAuthenticatedUsername())); break; case SyncSetupWizard::DONE: - flow_handler_->ShowSetupDone(service_->GetAuthenticatedUsername()); + flow_handler_->ShowSetupDone( + UTF16ToWide(service_->GetAuthenticatedUsername())); break; default: NOTREACHED() << "Invalid advance state: " << advance_state; diff --git a/chrome/browser/views/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h index 4bc7d60..32e3db1 100644 --- a/chrome/browser/views/sync/sync_setup_flow.h +++ b/chrome/browser/sync/sync_setup_flow.h @@ -4,8 +4,8 @@ #ifdef CHROME_PERSONALIZATION -#ifndef CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_FLOW_H_ -#define CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_FLOW_H_ +#ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ +#define CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ #include <string> #include <vector> @@ -14,7 +14,7 @@ #include "base/time.h" #include "chrome/browser/dom_ui/html_dialog_ui.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/views/sync/sync_setup_wizard.h" +#include "chrome/browser/sync/sync_setup_wizard.h" #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest_prod.h" @@ -185,5 +185,5 @@ class FlowHandler : public DOMMessageHandler { DISALLOW_COPY_AND_ASSIGN(FlowHandler); }; -#endif // CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_FLOW_H_ +#endif // CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ #endif // CHROME_PERSONALIZATION diff --git a/chrome/browser/views/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc index 31afcea..7d00ab9 100644 --- a/chrome/browser/views/sync/sync_setup_wizard.cc +++ b/chrome/browser/sync/sync_setup_wizard.cc @@ -4,7 +4,7 @@ #ifdef CHROME_PERSONALIZATION -#include "chrome/browser/views/sync/sync_setup_wizard.h" +#include "chrome/browser/sync/sync_setup_wizard.h" #include "app/resource_bundle.h" #include "base/message_loop.h" @@ -13,7 +13,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/dom_ui/chrome_url_data_manager.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/views/sync/sync_setup_flow.h" +#include "chrome/browser/sync/sync_setup_flow.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/url_constants.h" #include "grit/app_resources.h" diff --git a/chrome/browser/views/sync/sync_setup_wizard.h b/chrome/browser/sync/sync_setup_wizard.h index 1d36f61..d8a0d95 100644 --- a/chrome/browser/views/sync/sync_setup_wizard.h +++ b/chrome/browser/sync/sync_setup_wizard.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ -#define CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ +#ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ +#define CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ #include "base/basictypes.h" -#if defined(OS_WIN) -class SyncSetupFlowContainer; -#elif defined(OS_LINUX) +#if defined(OS_LINUX) typedef struct _GtkWidget GtkWidget; typedef struct _GtkWindow GtkWindow; +#else +class SyncSetupFlowContainer; #endif class ProfileSyncService; @@ -69,13 +69,14 @@ class SyncSetupWizard { ProfileSyncService* service_; -#if defined(OS_WIN) - SyncSetupFlowContainer* flow_container_; -#elif defined(OS_LINUX) +#if defined(OS_LINUX) bool visible_; +#else + SyncSetupFlowContainer* flow_container_; #endif DISALLOW_COPY_AND_ASSIGN(SyncSetupWizard); }; -#endif // CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ +#endif // CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ + diff --git a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc index fec7ef3..3a04746 100644 --- a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc @@ -11,8 +11,8 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/views/sync/sync_setup_flow.h" -#include "chrome/browser/views/sync/sync_setup_wizard.h" +#include "chrome/browser/sync/sync_setup_flow.h" +#include "chrome/browser/sync/sync_setup_wizard.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/test/browser_with_test_window_test.h" diff --git a/chrome/browser/sync/util/character_set_converters.h b/chrome/browser/sync/util/character_set_converters.h index 1db32c7..6a833ee 100644 --- a/chrome/browser/sync/util/character_set_converters.h +++ b/chrome/browser/sync/util/character_set_converters.h @@ -136,6 +136,21 @@ inline void AppendPathStringToUTF8(const PathString& wide, return AppendPathStringToUTF8(wide.data(), wide.length(), output_string); } +// Versions of UTF8ToPathString/PathStringToUTF8 that return the converted +// string directly. Any errors encountered will CHECK(). These functions are +// intended to be used only for testing. + +inline PathString UTF8ToPathStringQuick(const std::string &utf8) { + PathString wide; + CHECK(UTF8ToPathString(utf8.data(), utf8.size(), &wide)); + return wide; +} + +inline std::string PathStringToUTF8Quick(const PathString& wide) { + std::string utf8; + PathStringToUTF8(wide.data(), wide.size(), &utf8); + return utf8; +} inline bool Append(const PathChar* wide, int size, std::string* output_string) { diff --git a/chrome/browser/sync/util/user_settings_unittest.cc b/chrome/browser/sync/util/user_settings_unittest.cc index 952c86b..02f3fd8 100644 --- a/chrome/browser/sync/util/user_settings_unittest.cc +++ b/chrome/browser/sync/util/user_settings_unittest.cc @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE entry. +#include <string> + #include "base/file_util.h" #include "base/test/test_file_util.h" #include "chrome/browser/sync/syncable/directory_manager.h" +#include "chrome/browser/sync/util/character_set_converters.h" #include "chrome/browser/sync/util/user_settings.h" #include "chrome/browser/sync/util/query_helpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -40,15 +43,10 @@ class UserSettingsTest : public testing::Test { ExecOrDie(primer_handle, "CREATE TABLE shares" " (email, share_name, file_name," " PRIMARY KEY(email, share_name) ON CONFLICT REPLACE)"); -#if OS_WIN - // Populate a share. - ExecOrDie(primer_handle, "INSERT INTO shares values ( ?, ?, ?)", - "foo@foo.com", "foo@foo.com", WideToUTF8(kOldStyleSyncDataDB)); -#elif OS_LINUX // Populate a share. ExecOrDie(primer_handle, "INSERT INTO shares values ( ?, ?, ?)", - "foo@foo.com", "foo@foo.com", kOldStyleSyncDataDB); -#endif + "foo@foo.com", "foo@foo.com", + browser_sync::PathStringToUTF8Quick(kOldStyleSyncDataDB)); sqlite3_close(primer_handle); } diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 21b4970..c966ee8 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -16,6 +16,7 @@ #include "chrome/browser/cocoa/sad_tab_view.h" #import "chrome/browser/cocoa/web_drag_source.h" #import "chrome/browser/cocoa/web_drop_target.h" +#include "chrome/browser/renderer_host/render_view_host_factory.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" @@ -71,7 +72,16 @@ void TabContentsViewMac::CreateView(const gfx::Size& initial_size) { RenderWidgetHostView* TabContentsViewMac::CreateViewForWidget( RenderWidgetHost* render_widget_host) { - DCHECK(!render_widget_host->view()); + if (render_widget_host->view()) { + // During testing, the view will already be set up in most cases to the + // test view, so we don't want to clobber it with a real one. To verify that + // this actually is happening (and somebody isn't accidentally creating the + // view twice), we check for the RVH Factory, which will be set when we're + // making special ones (which go along with the special views). + DCHECK(RenderViewHostFactory::has_factory()); + return render_widget_host->view(); + } + RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(render_widget_host); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 1222730..8c47be4 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -155,7 +155,7 @@ }], # branding ], # conditions }], # OS=="mac" - ['OS=="win"', { + ['OS=="win" or OS=="mac"', { # Whether or not browser sync code is built in. 'chrome_personalization%': 1, }, { @@ -205,7 +205,7 @@ ['OS=="linux" and toolkit_views==1', {'sources/': [ ['include', '_views\\.cc$'], ]}], - ['OS=="win" and chrome_personalization==1', { + ['(OS=="win" or OS=="mac") and chrome_personalization==1', { 'defines': ['CHROME_PERSONALIZATION=1'], }], # chrome_personalization==1 ], @@ -2045,6 +2045,10 @@ 'browser/sync/glue/sync_backend_host.h', 'browser/sync/profile_sync_service.cc', 'browser/sync/profile_sync_service.h', + 'browser/sync/sync_setup_flow.cc', + 'browser/sync/sync_setup_flow.h', + 'browser/sync/sync_setup_wizard.cc', + 'browser/sync/sync_setup_wizard.h', 'browser/sync/sync_status_ui_helper.cc', 'browser/sync/sync_status_ui_helper.h', 'browser/tab_contents/constrained_window.h', @@ -2294,10 +2298,6 @@ 'browser/views/star_toggle.h', 'browser/views/status_bubble_views.cc', 'browser/views/status_bubble_views.h', - 'browser/views/sync/sync_setup_flow.cc', - 'browser/views/sync/sync_setup_flow.h', - 'browser/views/sync/sync_setup_wizard.cc', - 'browser/views/sync/sync_setup_wizard.h', 'browser/views/tab_icon_view.cc', 'browser/views/tab_icon_view.h', 'browser/views/tab_contents/tab_contents_container.cc', @@ -3922,6 +3922,7 @@ 'test/perf/mem_usage_mac.cc', 'test/perf/mem_usage_win.cc', 'test/perf/mem_usage.h', + 'test/test_browser_window.h', 'test/testing_profile.cc', 'test/testing_profile.h', 'test/ui_test_utils.cc', @@ -4552,6 +4553,7 @@ 'browser/sync/glue/bookmark_model_worker_unittest.cc', 'browser/sync/glue/http_bridge_unittest.cc', 'browser/sync/profile_sync_service_unittest.cc', + 'browser/sync/sync_setup_wizard_unittest.cc', 'browser/tab_contents/navigation_controller_unittest.cc', 'browser/tab_contents/navigation_entry_unittest.cc', 'browser/tab_contents/render_view_host_manager_unittest.cc', @@ -4563,7 +4565,6 @@ 'browser/utility_process_host_unittest.cc', 'browser/views/bookmark_context_menu_test.cc', 'browser/views/bookmark_editor_view_unittest.cc', - 'browser/views/sync/sync_setup_wizard_unittest.cc', 'browser/visitedlink_unittest.cc', 'browser/webdata/web_database_unittest.cc', 'browser/window_sizer_unittest.cc', @@ -4634,6 +4635,8 @@ 'browser/renderer_host/gtk_key_bindings_handler_unittest.cc', ], 'sources!': [ + # TODO(akalin): Figure out why this unittest fails on linux. + 'browser/browser_commands_unittest.cc', 'browser/views/bookmark_context_menu_test.cc', 'browser/gtk/options/cookies_view_unittest.cc', # Compact Language Detection (cld) is not supported in linux yet. @@ -4756,8 +4759,6 @@ 'browser/bookmarks/bookmark_drag_data_unittest.cc', 'browser/bookmarks/bookmark_folder_tree_model_unittest.cc', 'browser/bookmarks/bookmark_table_model_unittest.cc', - # Need to port browser_with_test_window_test.* first - 'browser/browser_commands_unittest.cc', 'browser/browser_unittest.cc', 'browser/extensions/extension_process_manager_unittest.cc', 'browser/importer/importer_unittest.cc', @@ -4769,11 +4770,8 @@ 'browser/views/bookmark_editor_view_unittest.cc', 'browser/views/find_bar_host_unittest.cc', 'browser/views/keyword_editor_view_unittest.cc', - 'browser/views/sync/sync_setup_wizard_unittest.cc', 'common/chrome_plugin_unittest.cc', 'common/net/url_util_unittest.cc', - 'test/browser_with_test_window_test.cc', - 'test/browser_with_test_window_test.h', ], }], ['chrome_personalization==1', { @@ -6711,6 +6709,10 @@ '-lsecur32.lib', ], }, + }, { # else: OS != "win" + 'sources!': [ + 'browser/sync/util/data_encryption_unittest.cc', + ], }], ['OS=="linux"', { 'defines': [ diff --git a/chrome/test/browser_with_test_window_test.cc b/chrome/test/browser_with_test_window_test.cc index 3e3fb93..8dede7c 100644 --- a/chrome/test/browser_with_test_window_test.cc +++ b/chrome/test/browser_with_test_window_test.cc @@ -12,7 +12,9 @@ BrowserWithTestWindowTest::BrowserWithTestWindowTest() : rph_factory_(), rvh_factory_(&rph_factory_) { +#if defined(OS_WIN) OleInitialize(NULL); +#endif } void BrowserWithTestWindowTest::SetUp() { @@ -38,7 +40,9 @@ BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); MessageLoop::current()->Run(); +#if defined(OS_WIN) OleUninitialize(); +#endif } TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( diff --git a/chrome/test/sync/engine/mock_server_connection.cc b/chrome/test/sync/engine/mock_server_connection.cc index 372d408..b2af891 100644 --- a/chrome/test/sync/engine/mock_server_connection.cc +++ b/chrome/test/sync/engine/mock_server_connection.cc @@ -43,9 +43,9 @@ MockConnectionManager::MockConnectionManager(DirectoryManager* dirmgr, directory_name_(name), mid_commit_callback_function_(NULL), mid_commit_observer_(NULL), - client_command_(NULL), throttling_(false), fail_non_periodic_get_updates_(false), + client_command_(NULL), next_position_in_parent_(2) { server_reachable_ = true; }; @@ -405,4 +405,5 @@ void MockConnectionManager::ThrottleNextRequest( throttling_ = true; if (visitor) visitor->VisitAtomically(); -}
\ No newline at end of file +} + diff --git a/chrome/test/sync/engine/test_directory_setter_upper.cc b/chrome/test/sync/engine/test_directory_setter_upper.cc index 2685795..9e910f0 100644 --- a/chrome/test/sync/engine/test_directory_setter_upper.cc +++ b/chrome/test/sync/engine/test_directory_setter_upper.cc @@ -85,12 +85,6 @@ void ManuallyOpenedTestDirectorySetterUpper::TearDown() { TestDirectorySetterUpper::TearDown(); } } - -static PathString UTF8ToPathStringQuick(const std::string &str) { - PathString ret; - CHECK(browser_sync::UTF8ToPathString(str.data(), str.size(), &ret)); - return ret; -} TriggeredOpenTestDirectorySetterUpper::TriggeredOpenTestDirectorySetterUpper( const std::string& name) diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h index 8aa657d..d785415 100644 --- a/chrome/test/test_browser_window.h +++ b/chrome/test/test_browser_window.h @@ -7,18 +7,14 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" -#include "chrome/browser/views/tabs/tab_strip.h" #include "chrome/test/test_location_bar.h" // An implementation of BrowserWindow used for testing. TestBrowserWindow only -// contains a valid TabStrip, all other getters return NULL. +// contains a valid LocationBar, all other getters return NULL. // See BrowserWithTestWindowTest for an example of using this class. class TestBrowserWindow : public BrowserWindow { public: - explicit TestBrowserWindow(Browser* browser) - : tab_strip_(browser->tabstrip_model()) { - tab_strip_.InitTabStripButtons(); - } + explicit TestBrowserWindow(Browser* browser) {} virtual ~TestBrowserWindow() {} virtual void Init() {} @@ -91,8 +87,6 @@ class TestBrowserWindow : public BrowserWindow { virtual void DestroyBrowser() {} private: - TabStrip tab_strip_; - TestLocationBar location_bar_; DISALLOW_COPY_AND_ASSIGN(TestBrowserWindow); |