OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 #include <string> | |
bartfab (slow)
2015/04/01 14:22:42
Nit: Add a blank line above.
peletskyi
2015/04/01 18:55:46
Done.
| |
5 | |
6 #include "ash/display/display_manager.h" | |
7 #include "ash/shell.h" | |
8 #include "ash/test/display_manager_test_api.h" | |
9 #include "ash/wm/window_positioner.h" | |
10 #include "base/strings/string_number_conversions.h" | |
11 #include "chrome/browser/chromeos/policy/login_policy_test_base.h" | |
12 #include "chrome/browser/profiles/profile_manager.h" | |
13 #include "chrome/browser/ui/browser.h" | |
14 #include "chrome/browser/ui/browser_list.h" | |
15 #include "chrome/browser/ui/browser_window.h" | |
16 #include "chrome/browser/ui/host_desktop.h" | |
17 #include "policy/policy_constants.h" | |
18 #include "testing/gtest/include/gtest/gtest.h" | |
19 | |
20 namespace policy { | |
21 | |
22 class ForceMaximizeOnFirstRunTest : public LoginPolicyTestBase { | |
23 protected: | |
24 ForceMaximizeOnFirstRunTest() : LoginPolicyTestBase(){}; | |
bartfab (slow)
2015/04/01 14:22:42
Nit: s/{};/ {}/
peletskyi
2015/04/01 18:55:45
Done.
| |
25 | |
26 std::string GetMandatoryPolicies() const override { | |
27 return "\"" + std::string(key::kForceMaximizeOnFirstRun) + "\": true"; | |
28 } | |
29 | |
30 void SetUpResolution() { | |
31 // Set width of the screen wider than limit, after which the browser window | |
32 // is *NOT* maximized by default. | |
bartfab (slow)
2015/04/01 14:22:42
Nit: The sentence is a bit hard to parse. How abou
peletskyi
2015/04/01 18:55:46
Done.
| |
33 const int width = | |
34 ash::WindowPositioner::GetForceMaximizedWidthLimit() + 100; | |
35 // Set resolution to 1466x300. | |
36 const std::string resolution = base::IntToString(width) + "x300"; | |
37 ash::DisplayManager* display_manager = | |
bartfab (slow)
2015/04/01 14:22:42
Nit: const pointer.
peletskyi
2015/04/01 18:55:46
ash::test::DisplayManagerTestApi takes non-const p
bartfab (slow)
2015/04/02 08:44:28
It takes a pointer to non-const, but it does not c
peletskyi
2015/04/02 12:53:28
Done.
| |
38 ash::Shell::GetInstance()->display_manager(); | |
39 ash::test::DisplayManagerTestApi display_manager_test_api(display_manager); | |
40 display_manager_test_api.UpdateDisplay(resolution); | |
41 } | |
42 | |
43 private: | |
44 DISALLOW_COPY_AND_ASSIGN(ForceMaximizeOnFirstRunTest); | |
bartfab (slow)
2015/04/01 14:22:42
Nit: #include "base/macros.h"
peletskyi
2015/04/01 18:55:46
Done.
| |
45 }; | |
46 | |
47 IN_PROC_BROWSER_TEST_F(ForceMaximizeOnFirstRunTest, PRE_TwoRuns) { | |
48 SetUpResolution(); | |
49 SkipToLoginScreen(); | |
50 LogIn(kAccountId, kAccountPassword); | |
51 | |
52 // Check that the first browser window is maximized. | |
53 const BrowserList* browser_list = | |
bartfab (slow)
2015/04/01 14:22:42
Nit: const pointer.
peletskyi
2015/04/01 18:55:46
Already const
bartfab (slow)
2015/04/02 08:44:28
This is a pointer to const. Make it a const pointe
peletskyi
2015/04/02 12:53:29
Done.
| |
54 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | |
55 EXPECT_EQ(1U, browser_list->size()); | |
56 Browser* browser = browser_list->get(0); | |
bartfab (slow)
2015/04/01 14:22:42
Nit: const pointer.
peletskyi
2015/04/01 18:55:45
Done.
bartfab (slow)
2015/04/02 08:44:28
Nice to see that it can be a pointer to coinst. Pl
peletskyi
2015/04/02 12:53:28
Done.
| |
57 ASSERT_TRUE(browser); | |
58 EXPECT_TRUE(browser->window()->IsMaximized()); | |
59 | |
60 browser->window()->Restore(); | |
bartfab (slow)
2015/04/01 14:22:41
Nit: Add a comment that you need to un-maximize th
peletskyi
2015/04/01 18:55:46
Done.
| |
61 EXPECT_FALSE(browser->window()->IsMaximized()); | |
62 | |
63 // Create the second window and check if it is not affected by policy. | |
bartfab (slow)
2015/04/01 14:22:42
Nit 1: a/the/a/
Nit 2: s/if/that/
peletskyi
2015/04/01 18:55:46
Done.
| |
64 Browser* browser1 = CreateBrowser(ProfileManager::GetActiveUserProfile()); | |
bartfab (slow)
2015/04/01 14:22:41
1: As with chrome_shell_delegate.cc, the documenta
bartfab (slow)
2015/04/02 08:44:28
1: This was not not addressed.
2: Please make |bro
peletskyi
2015/04/02 12:53:28
Done.
| |
65 ASSERT_TRUE(browser); | |
66 EXPECT_FALSE(browser1->window()->IsMaximized()); | |
67 } | |
68 | |
69 IN_PROC_BROWSER_TEST_F(ForceMaximizeOnFirstRunTest, TwoRuns) { | |
70 SetUpResolution(); | |
71 content::WindowedNotificationObserver( | |
bartfab (slow)
2015/04/01 14:22:41
Nit: #include "content/public/test/test_utils.h"
peletskyi
2015/04/01 18:55:45
Done.
| |
72 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | |
bartfab (slow)
2015/04/01 14:22:42
Nit: #include "chrome/browser/chrome_notification_
peletskyi
2015/04/01 18:55:46
Done.
| |
73 content::NotificationService::AllSources()).Wait(); | |
bartfab (slow)
2015/04/01 14:22:42
Nit: #include "content/public/browser/notification
peletskyi
2015/04/01 18:55:46
Done.
| |
74 | |
bartfab (slow)
2015/04/01 14:22:42
Nit: For consistency with the first test, remove t
peletskyi
2015/04/01 18:55:46
Done.
| |
75 LogIn(kAccountId, kAccountPassword); | |
76 | |
77 Browser* browser = CreateBrowser(ProfileManager::GetActiveUserProfile()); | |
bartfab (slow)
2015/04/01 14:22:42
Nit: const pointer.
peletskyi
2015/04/01 18:55:46
Done.
bartfab (slow)
2015/04/02 08:44:28
Please make this a const pointer to const.
peletskyi
2015/04/02 12:53:28
Done.
| |
78 ASSERT_TRUE(browser); | |
79 EXPECT_FALSE(browser->window()->IsMaximized()); | |
80 } | |
81 | |
82 class ForceMaximizetPolicyFalseTest : public ForceMaximizeOnFirstRunTest { | |
83 protected: | |
84 ForceMaximizetPolicyFalseTest() : ForceMaximizeOnFirstRunTest(){}; | |
bartfab (slow)
2015/04/01 14:22:42
Nit: s/{};/ {}/
peletskyi
2015/04/01 18:55:46
Done.
| |
85 std::string GetMandatoryPolicies() const override { | |
bartfab (slow)
2015/04/01 14:22:42
Nit: Add a blank line above.
peletskyi
2015/04/01 18:55:46
Done.
| |
86 return "\"" + std::string(key::kForceMaximizeOnFirstRun) + "\": false"; | |
87 } | |
88 | |
89 private: | |
90 DISALLOW_COPY_AND_ASSIGN(ForceMaximizetPolicyFalseTest); | |
91 }; | |
92 | |
93 IN_PROC_BROWSER_TEST_F(ForceMaximizetPolicyFalseTest, GeneralFirstRun) { | |
94 SetUpResolution(); | |
95 | |
bartfab (slow)
2015/04/01 14:22:42
Nit: For consistency with the first test, remove t
peletskyi
2015/04/02 12:53:28
Done.
| |
96 SkipToLoginScreen(); | |
97 LogIn(kAccountId, kAccountPassword); | |
98 | |
99 const BrowserList* browser_list = | |
bartfab (slow)
2015/04/01 14:22:42
Nit: Const pointer.
peletskyi
2015/04/01 18:55:46
Done.
bartfab (slow)
2015/04/02 08:44:28
Please make this a const pointer to const.
peletskyi
2015/04/02 12:53:29
Done.
| |
100 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | |
101 EXPECT_EQ(1U, browser_list->size()); | |
102 const Browser* browser = browser_list->get(0); | |
bartfab (slow)
2015/04/01 14:22:42
Nit: Const pointer.
peletskyi
2015/04/01 18:55:46
Done.
bartfab (slow)
2015/04/02 08:44:28
Please make this a const pointer to const.
peletskyi
2015/04/02 12:53:28
Done.
| |
103 ASSERT_TRUE(browser); | |
104 EXPECT_FALSE(browser->window()->IsMaximized()); | |
105 } | |
106 | |
107 } // namespace policy | |
OLD | NEW |