OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "extensions/shell/browser/shell_native_app_window_aura.h" | |
6 | |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "content/public/browser/browser_context.h" | |
9 #include "content/public/browser/notification_service.h" | |
10 #include "content/public/browser/web_contents.h" | |
11 #include "content/public/test/test_browser_context.h" | |
12 #include "content/public/test/test_browser_thread_bundle.h" | |
13 #include "extensions/browser/app_window/app_window.h" | |
14 #include "extensions/browser/app_window/test_app_window_contents.h" | |
15 #include "extensions/browser/extensions_test.h" | |
16 #include "extensions/common/extension.h" | |
17 #include "extensions/common/extension_builder.h" | |
18 #include "extensions/shell/browser/desktop_controller.h" | |
19 #include "extensions/shell/browser/shell_app_delegate.h" | |
20 #include "extensions/shell/browser/shell_app_window_client.h" | |
21 #include "ui/gfx/geometry/rect.h" | |
22 | |
23 namespace extensions { | |
24 | |
25 class ShellNativeAppWindowAuraTest : public ExtensionsTest { | |
26 public: | |
27 ShellNativeAppWindowAuraTest() | |
28 : notification_service_(content::NotificationService::Create()) { | |
James Cook
2014/11/17 20:54:22
Not necessarily for this CL: I think we should cre
Yoyo Zhou
2014/11/17 23:55:26
I agree. Added a TODO.
| |
29 AppWindowClient::Set(&app_window_client_); | |
30 } | |
31 | |
32 ~ShellNativeAppWindowAuraTest() override {} | |
33 | |
34 void TearDown() override { ExtensionsTest::TearDown(); } | |
James Cook
2014/11/17 20:54:22
not needed
Yoyo Zhou
2014/11/17 23:55:26
Done.
| |
35 | |
36 protected: | |
37 content::TestBrowserThreadBundle thread_bundle_; | |
38 scoped_ptr<content::NotificationService> notification_service_; | |
39 ShellAppWindowClient app_window_client_; | |
40 }; | |
41 | |
42 TEST_F(ShellNativeAppWindowAuraTest, Bounds) { | |
43 // The BrowserContext used here must be destroyed before the thread bundle, | |
44 // because of destructors of things spawned from creating a WebContents. | |
45 scoped_ptr<content::BrowserContext> browser_context( | |
46 new content::TestBrowserContext); | |
47 scoped_refptr<Extension> extension = | |
48 ExtensionBuilder() | |
49 .SetManifest(DictionaryBuilder() | |
50 .Set("name", "test extension") | |
51 .Set("version", "1") | |
52 .Set("manifest_version", 2)) | |
53 .Build(); | |
54 | |
55 AppWindow* app_window = new AppWindow( | |
56 browser_context.get(), new ShellAppDelegate, extension.get()); | |
57 content::WebContents* web_contents = content::WebContents::Create( | |
58 content::WebContents::CreateParams(browser_context.get())); | |
59 app_window->SetAppWindowContentsForTesting( | |
60 make_scoped_ptr(new TestAppWindowContents(web_contents))); | |
61 | |
62 AppWindow::BoundsSpecification window_spec; | |
63 window_spec.bounds = gfx::Rect(100, 200, 300, 400); | |
James Cook
2014/11/17 20:54:22
+1 for varying the data!
| |
64 AppWindow::CreateParams params; | |
65 params.window_spec = window_spec; | |
66 | |
67 ShellNativeAppWindowAura window(app_window, params); | |
68 | |
69 gfx::Rect bounds = window.GetBounds(); | |
70 ASSERT_EQ(window_spec.bounds, bounds); | |
James Cook
2014/11/17 20:54:22
EXPECT_EQ? Do you want the test to crash if this d
Yoyo Zhou
2014/11/17 23:55:26
Done.
| |
71 | |
72 // Delete the AppWindow. | |
73 app_window->OnNativeClose(); | |
74 } | |
75 | |
76 } // namespace extensions | |
James Cook
2014/11/17 20:54:22
Thanks for writing this test. I know it was a pain
| |
OLD | NEW |