Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/ui/panels/panel_browser_view_browsertest.cc

Issue 7011015: Show "About panel" bubble on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/i18n/time_formatting.h"
7 #include "chrome/browser/extensions/extension_service.h"
6 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/panels/about_panel_bubble.h"
9 #include "chrome/browser/ui/panels/panel.h" 12 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" 13 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
11 #include "chrome/browser/ui/panels/panel_browser_view.h" 14 #include "chrome/browser/ui/panels/panel_browser_view.h"
15 #include "chrome/browser/web_applications/web_app.h"
12 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/extension.h"
13 #include "chrome/test/in_process_browser_test.h" 18 #include "chrome/test/in_process_browser_test.h"
19 #include "grit/generated_resources.h"
20 #include "ui/base/l10n/l10n_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
15 #include "views/controls/button/image_button.h" 22 #include "views/controls/button/image_button.h"
16 #include "views/controls/button/menu_button.h" 23 #include "views/controls/button/menu_button.h"
24 #include "views/controls/image_view.h"
17 #include "views/controls/label.h" 25 #include "views/controls/label.h"
26 #include "views/controls/link.h"
27 #include "views/controls/textfield/textfield.h"
18 #include "views/controls/menu/menu_2.h" 28 #include "views/controls/menu/menu_2.h"
19 29
20
21 class PanelBrowserViewTest : public InProcessBrowserTest { 30 class PanelBrowserViewTest : public InProcessBrowserTest {
22 public: 31 public:
23 PanelBrowserViewTest() : InProcessBrowserTest() { } 32 PanelBrowserViewTest() : InProcessBrowserTest() { }
24 33
25 virtual void SetUpCommandLine(CommandLine* command_line) { 34 virtual void SetUpCommandLine(CommandLine* command_line) {
26 command_line->AppendSwitch(switches::kEnablePanels); 35 command_line->AppendSwitch(switches::kEnablePanels);
27 } 36 }
28 37
29 protected: 38 protected:
30 PanelBrowserView* CreatePanelBrowserView(const std::string& panel_name) { 39 PanelBrowserView* CreatePanelBrowserView(const std::string& panel_name) {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 expected_delta_x_without_change, 366 expected_delta_x_without_change,
358 false); 367 false);
359 } 368 }
360 369
361 // Closes all panels. 370 // Closes all panels.
362 for (size_t i = 0; i < browser_view_count; ++i) { 371 for (size_t i = 0; i < browser_view_count; ++i) {
363 browser_views[i]->panel()->Close(); 372 browser_views[i]->panel()->Close();
364 EXPECT_FALSE(browser_views[i]->panel()); 373 EXPECT_FALSE(browser_views[i]->panel());
365 } 374 }
366 } 375 }
376
377 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, AboutPanelBubble) {
378 ExtensionService* extension_service =
379 browser()->GetProfile()->GetExtensionService();
380
381 // Create a testing extension.
jennb 2011/05/24 05:29:14 Could you do like the extension tests and create a
jianli 2011/05/24 18:20:24 I do not think we need to host a real extension si
382 #if defined(OS_WIN)
383 FilePath path(FILE_PATH_LITERAL("c:\\foo"));
384 #else
385 FilePath path(FILE_PATH_LITERAL("/foo"));
367 #endif 386 #endif
387 DictionaryValue input_value;
388 input_value.SetString(extension_manifest_keys::kVersion, "1.0.0.0");
389 input_value.SetString(extension_manifest_keys::kName, "Sample Extension");
390 input_value.SetString(extension_manifest_keys::kDescription,
391 "Sample Description");
392 scoped_refptr<Extension> extension(Extension::Create(path, Extension::INVALID,
393 input_value, Extension::STRICT_ERROR_CHECKS, NULL));
394 ASSERT_TRUE(extension.get());
395 extension_service->AddExtension(extension.get());
396
397 // Create a panel with the app name that comes from the extension ID.
398 PanelBrowserView* browser_view = CreatePanelBrowserView(
399 web_app::GenerateApplicationNameFromExtensionId(extension->id()));
400
401 AboutPanelBubble* bubble = AboutPanelBubble::Show(
402 browser_view->GetWidget(),
403 gfx::Rect(),
404 BubbleBorder::BOTTOM_RIGHT,
405 SkBitmap(),
406 browser_view->browser());
407 AboutPanelBubble::AboutPanelBubbleView* contents =
408 static_cast<AboutPanelBubble::AboutPanelBubbleView*>(bubble->contents());
409
410 // We should have the expected controls.
411 EXPECT_EQ(6, contents->child_count());
412 EXPECT_TRUE(contents->Contains(contents->icon_));
413 EXPECT_TRUE(contents->Contains(contents->title_));
414 EXPECT_TRUE(contents->Contains(contents->install_date_));
415 EXPECT_TRUE(contents->Contains(contents->description_));
416 EXPECT_TRUE(contents->Contains(contents->uninstall_link_));
417 EXPECT_TRUE(contents->Contains(contents->report_abuse_link_));
418
419 // These controls should be visible.
420 EXPECT_TRUE(contents->icon_->IsVisible());
421 EXPECT_TRUE(contents->title_->IsVisible());
422 EXPECT_TRUE(contents->install_date_->IsVisible());
423 EXPECT_TRUE(contents->description_->IsVisible());
424 EXPECT_TRUE(contents->uninstall_link_->IsVisible());
425 EXPECT_TRUE(contents->report_abuse_link_->IsVisible());
426
427 // Validate their layouts.
428 EXPECT_GT(contents->title_->x(), contents->icon_->x());
429 EXPECT_GT(contents->title_->width(), 0);
430 EXPECT_GT(contents->title_->height(), 0);
431 EXPECT_EQ(contents->install_date_->x(), contents->title_->x());
432 EXPECT_GT(contents->install_date_->y(), contents->title_->y());
433 EXPECT_GT(contents->install_date_->width(), 0);
434 EXPECT_GT(contents->install_date_->height(), 0);
435 EXPECT_EQ(contents->description_->x(), contents->install_date_->x());
436 EXPECT_GT(contents->description_->y(), contents->install_date_->y());
437 EXPECT_GT(contents->description_->width(), 0);
438 EXPECT_GT(contents->description_->height(), 0);
439 EXPECT_EQ(contents->uninstall_link_->x(), contents->description_->x());
440 EXPECT_GT(contents->uninstall_link_->y(), contents->description_->y());
441 EXPECT_GT(contents->uninstall_link_->width(), 0);
442 EXPECT_GT(contents->uninstall_link_->height(), 0);
443 EXPECT_GT(contents->report_abuse_link_->x(), contents->uninstall_link_->x());
444 EXPECT_EQ(contents->report_abuse_link_->y(), contents->uninstall_link_->y());
445 EXPECT_GT(contents->report_abuse_link_->width(), 0);
446 EXPECT_GT(contents->report_abuse_link_->height(), 0);
447
448 // Validates the texts.
449 base::Time install_time =
450 extension_service->extension_prefs()->GetInstallTime(extension->id());
451 string16 time_text = l10n_util::GetStringFUTF16(
452 IDS_ABOUT_PANEL_BUBBLE_EXTENSION_INSTALL_DATE,
453 base::TimeFormatFriendlyDate(
454 extension_service->extension_prefs()->GetInstallTime(
455 extension->id())));
456 EXPECT_STREQ(UTF16ToUTF8(time_text).c_str(),
457 WideToUTF8(contents->install_date_->GetText()).c_str());
458 EXPECT_STREQ(extension->description().c_str(),
459 UTF16ToUTF8(contents->description_->text()).c_str());
460 }
461 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698