Commit f4884283 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

mac: break bookmark test deps on CocoaProfileTest

These now use BrowserWithTestWindowTest instead. The only wrinkle
was that both of these suites need to set up and wait for the bookmark
service to be ready.

Bug: 39725
Change-Id: I45be03eeade25ac2a0b5b002e81f2f8a46ae0d6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108962Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752020}
parent 34c14a46
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
#import <AppKit/AppKit.h>
#include "base/guid.h"
......@@ -9,10 +11,12 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
#include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
......@@ -21,22 +25,24 @@ using base::ASCIIToUTF16;
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
// TODO(jrg): see refactor comment in bookmark_bar_state_controller_unittest.mm
class BookmarkMenuBridgeTest : public CocoaProfileTest {
class BookmarkMenuBridgeTest : public BrowserWithTestWindowTest {
public:
BookmarkMenuBridgeTest() {}
void SetUp() override {
CocoaProfileTest::SetUp();
ASSERT_TRUE(profile());
BrowserWithTestWindowTest::SetUp();
menu_.reset([[NSMenu alloc] initWithTitle:@"test"]);
bridge_ = std::make_unique<BookmarkMenuBridge>(profile(), menu_);
profile()->CreateBookmarkModel(true);
bookmarks::test::WaitForBookmarkModelToLoad(
BookmarkModelFactory::GetForBrowserContext(profile()));
menu_.reset([[NSMenu alloc] initWithTitle:@"test"]);
bridge_ = std::make_unique<BookmarkMenuBridge>(profile(), menu_);
}
void TearDown() override {
bridge_ = nullptr;
CocoaProfileTest::TearDown();
BrowserWithTestWindowTest::TearDown();
}
void UpdateRootMenu() { bridge_->UpdateMenu(menu_, nullptr); }
......@@ -76,6 +82,8 @@ class BookmarkMenuBridgeTest : public CocoaProfileTest {
std::unique_ptr<BookmarkMenuBridge> bridge_;
private:
CocoaTestHelper cocoa_test_helper_;
DISALLOW_COPY_AND_ASSIGN(BookmarkMenuBridgeTest);
};
......
......@@ -2,15 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
#import "base/mac/scoped_nsobject.h"
#include "base/strings/string16.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/ui/browser.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
#include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h"
#include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
using bookmarks::BookmarkModel;
......@@ -53,12 +56,14 @@ using bookmarks::BookmarkNode;
@end // FakeBookmarkMenuController
class BookmarkMenuCocoaControllerTest : public CocoaProfileTest {
class BookmarkMenuCocoaControllerTest : public BrowserWithTestWindowTest {
public:
void SetUp() override {
CocoaProfileTest::SetUp();
ASSERT_TRUE(profile());
BrowserWithTestWindowTest::SetUp();
profile()->CreateBookmarkModel(true);
bookmarks::test::WaitForBookmarkModelToLoad(
BookmarkModelFactory::GetForBrowserContext(profile()));
controller_.reset(
[[FakeBookmarkMenuController alloc] initWithProfile:profile()]);
}
......@@ -66,6 +71,7 @@ class BookmarkMenuCocoaControllerTest : public CocoaProfileTest {
FakeBookmarkMenuController* controller() { return controller_.get(); }
private:
CocoaTestHelper cocoa_test_helper_;
base::scoped_nsobject<FakeBookmarkMenuController> controller_;
};
......
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