Skip to content

Commit

Permalink
Mac/Aura aura_shell_unittests are not linking
Browse files Browse the repository at this point in the history
Gets aura_shell_unittests compiling and passing on Mac.  Some
unimplemented tests were disabled.  The AuraShell.app is built
to provide the tests with proper resources.  Also, references
to the ui::Compositor are now getting released during tear down.

BUG=111279
TEST=aura_shell_unittests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119686 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dhollowa@chromium.org committed Jan 30, 2012
1 parent 87e8b11 commit a0fea7e
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 8 deletions.
13 changes: 12 additions & 1 deletion ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
'test/test_shell_delegate.h',
'test/test_suite.cc',
'test/test_suite.h',
'test/test_suite_init.h',
'test/test_suite_init.mm',
'tooltips/tooltip_controller_unittest.cc',
'wm/activation_controller_unittest.cc',
'wm/base_layout_manager_unittest.cc',
Expand Down Expand Up @@ -251,8 +253,17 @@
}],
['OS=="mac"', {
'sources/': [
['exclude', 'accelerators/accelerator_filter_unittest.cc'],
['exclude', 'drag_drop/drag_drop_controller_unittest.cc'],
['exclude', 'tooltips/tooltip_controller_unittest.cc'],
],
'dependencies': [
# Mac tests access resources via the 'AuraShell.app' directory.
'ash_shell',
],
# Special linker instructions that avoids stripping Obj-C classes that
# are not referenced in code, but are referenced in nibs.
'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']},
}],
],
},
Expand Down Expand Up @@ -283,8 +294,8 @@
'shell/example_factory.h',
'shell/lock_view.cc',
'shell/shell_main.cc',
'shell/shell_main_parts.h',
'shell/shell_main_parts.cc',
'shell/shell_main_parts.h',
'shell/shell_main_parts_mac.mm',
'shell/toplevel_window.cc',
'shell/toplevel_window.h',
Expand Down
10 changes: 8 additions & 2 deletions ash/test/test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#include "build/build_config.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/compositor/compositor_setup.h"
#include "ui/gfx/compositor/test/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h"

#include "ui/gfx/compositor/compositor_setup.h"
#if defined(OS_MACOSX)
#include "ash/test/test_suite_init.h"
#endif

namespace ash {
namespace test {
Expand All @@ -26,6 +29,10 @@ void AuraShellTestSuite::Initialize() {
gfx::RegisterPathProvider();
ui::RegisterPathProvider();

#if defined(OS_MACOSX)
ash::test::OverrideFrameworkBundle();
#endif

// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
Expand All @@ -36,7 +43,6 @@ void AuraShellTestSuite::Initialize() {
void AuraShellTestSuite::Shutdown() {
ui::CompositorTestSupport::Terminate();
ui::ResourceBundle::CleanupSharedInstance();

base::TestSuite::Shutdown();
}

Expand Down
11 changes: 11 additions & 0 deletions ash/test/test_suite_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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.

namespace ash {
namespace test {

void OverrideFrameworkBundle();

} // namespace test
} // namespace ash
26 changes: 26 additions & 0 deletions ash/test/test_suite_init.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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 "ash/test/test_suite_init.h"

#import <Cocoa/Cocoa.h>

#include "base/file_path.h"
#include "base/mac/bundle_locations.h"
#include "base/memory/scoped_nsobject.h"
#include "base/path_service.h"

namespace ash {
namespace test {

void OverrideFrameworkBundle() {
// Look in the AuraShell.app directory for resources.
FilePath path;
PathService::Get(base::DIR_EXE, &path);
path = path.Append(FILE_PATH_LITERAL("AuraShell.app"));
base::mac::SetOverrideFrameworkBundlePath(path);
}

} // namespace test
} // namespace ash
9 changes: 8 additions & 1 deletion ash/wm/base_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,16 @@ TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) {
window->bounds());
}

// Fails on Mac only. Need to be implemented. http://crbug.com/111279.
#if defined(OS_MACOSX)
#define MAYBE_RootWindowResizeShrinksWindows \
FAILS_RootWindowResizeShrinksWindows
#else
#define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows
#endif
// Tests that when the screen gets smaller the windows aren't bigger than
// the screen.
TEST_F(BaseLayoutManagerTest, RootWindowResizeShrinksWindows) {
TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) {
scoped_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(10, 20, 500, 400)));
gfx::Rect work_area = gfx::Screen::GetMonitorAreaNearestWindow(window.get());
Expand Down
8 changes: 7 additions & 1 deletion ash/wm/shelf_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ ShelfLayoutManager* GetShelfLayoutManager() {

typedef ash::test::AuraShellTestBase ShelfLayoutManagerTest;

// Fails on Mac only. Need to be implemented. http://crbug.com/111279.
#if defined(OS_MACOSX)
#define MAYBE_SetVisible FAILS_SetVisible
#else
#define MAYBE_SetVisible SetVisible
#endif
// Makes sure SetVisible updates work area and widget appropriately.
TEST_F(ShelfLayoutManagerTest, SetVisible) {
TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
// Force an initial layout.
shelf->LayoutShelf();
Expand Down
9 changes: 8 additions & 1 deletion ash/wm/toplevel_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,16 @@ TEST_F(ToplevelLayoutManagerTest, FullscreenRootWindowResize) {
window->bounds());
}

// Fails on Mac only. Need to be implemented. http://crbug.com/111279.
#if defined(OS_MACOSX)
#define MAYBE_RootWindowResizeShrinksWindows \
FAILS_RootWindowResizeShrinksWindows
#else
#define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows
#endif
// Tests that when the screen gets smaller the windows aren't bigger than
// the screen.
TEST_F(ToplevelLayoutManagerTest, RootWindowResizeShrinksWindows) {
TEST_F(ToplevelLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) {
scoped_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(10, 20, 500, 400)));
gfx::Rect work_area = gfx::Screen::GetMonitorAreaNearestWindow(window.get());
Expand Down
4 changes: 4 additions & 0 deletions ui/aura/root_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ RootWindow::~RootWindow() {
// Make sure to destroy the compositor before terminating so that state is
// cleared and we don't hit asserts.
compositor_ = NULL;

// Tear down in reverse. Frees any references held by the host.
host_.reset(NULL);

// An observer may have been added by an animation on the RootWindow.
layer()->GetAnimator()->RemoveObserver(this);
ui::Compositor::Terminate();
Expand Down
12 changes: 10 additions & 2 deletions ui/aura/root_window_host_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>

#include "base/compiler_specific.h"
#include "base/mac/bundle_locations.h"
#include "base/memory/scoped_nsobject.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
Expand Down Expand Up @@ -74,13 +75,20 @@

RootWindowHostMac::RootWindowHostMac(const gfx::Rect& bounds)
: root_window_(NULL), bounds_(bounds) {
controller_.reset([[NSWindowController alloc]
initWithWindowNibName:@"RootWindow"]);
NSString* nibpath = [base::mac::FrameworkBundle()
pathForResource:@"RootWindow"
ofType:@"nib"];
NSWindowController* controller = [NSWindowController alloc];
controller_.reset([controller initWithWindowNibPath:nibpath
owner:controller]);
SetSize(bounds.size());
SetLocation(bounds);
}

RootWindowHostMac::~RootWindowHostMac() {
RootWindowView* view = [[controller_ window] contentView];
[view setCompositor:NULL];
[controller_ close];
}

// static
Expand Down

0 comments on commit a0fea7e

Please sign in to comment.