How to use Err method of launcher Package

Best Rod code snippet using launcher.Err

remove_apps_from_folder.go

Source:remove_apps_from_folder.go Github

copy

Full Screen

1// Copyright 2021 The Chromium OS Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4package launcher5import (6 "context"7 "io/ioutil"8 "os"9 "chromiumos/tast/local/chrome"10 "chromiumos/tast/local/chrome/ash"11 "chromiumos/tast/local/chrome/uiauto"12 "chromiumos/tast/local/chrome/uiauto/launcher"13 "chromiumos/tast/testing"14 "chromiumos/tast/testing/hwdep"15)16func init() {17 testing.AddTest(&testing.Test{18 Func: RemoveAppsFromFolder,19 LacrosStatus: testing.LacrosVariantUnneeded,20 Desc: "Test removing items from a folder in the launcher",21 Contacts: []string{22 "cros-system-ui-eng@google.com",23 "chromeos-sw-engprod@google.com",24 "mmourgos@chromium.org"},25 Attr: []string{"group:mainline", "informational"},26 SoftwareDeps: []string{"chrome"},27 Params: []testing.Param{{28 Name: "productivity_launcher_clamshell_mode",29 Val: launcher.TestCase{ProductivityLauncher: true, TabletMode: false},30 }, {31 Name: "clamshell_mode",32 Val: launcher.TestCase{ProductivityLauncher: false, TabletMode: false},33 }, {34 Name: "productivity_launcher_tablet_mode",35 Val: launcher.TestCase{ProductivityLauncher: true, TabletMode: true},36 ExtraHardwareDeps: hwdep.D(hwdep.InternalDisplay()),37 }, {38 Name: "tablet_mode",39 Val: launcher.TestCase{ProductivityLauncher: false, TabletMode: true},40 ExtraHardwareDeps: hwdep.D(hwdep.InternalDisplay()),41 }},42 })43}44// RemoveAppsFromFolder tests that items can be removed from a folder.45func RemoveAppsFromFolder(ctx context.Context, s *testing.State) {46 extDirBase, err := ioutil.TempDir("", "")47 if err != nil {48 s.Fatal("Failed to create a temporary directory: ", err)49 }50 defer os.RemoveAll(extDirBase)51 // Create 10 fake apps and get the the options to add to the new chrome session.52 opts, err := ash.GeneratePrepareFakeAppsOptions(extDirBase, 10)53 if err != nil {54 s.Fatal("Failed to create 10 fake apps")55 }56 testCase := s.Param().(launcher.TestCase)57 productivityLauncher := testCase.ProductivityLauncher58 if productivityLauncher {59 opts = append(opts, chrome.EnableFeatures("ProductivityLauncher"))60 } else {61 opts = append(opts, chrome.DisableFeatures("ProductivityLauncher"))62 }63 // Creating fake apps and logging into a new session in this test ensures that enough apps will be available to folder.64 cr, err := chrome.New(ctx, opts...)65 if err != nil {66 s.Fatal("Chrome login failed: ", err)67 }68 defer cr.Close(ctx)69 tconn, err := cr.TestAPIConn(ctx)70 if err != nil {71 s.Fatal("Failed to connect to test API: ", err)72 }73 tabletMode := testCase.TabletMode74 cleanup, err := ash.EnsureTabletModeEnabled(ctx, tconn, tabletMode)75 if err != nil {76 s.Fatalf("Failed to ensure tablet mode state %t: %v", tabletMode, err)77 }78 defer cleanup(ctx)79 if !tabletMode {80 if err := ash.WaitForLauncherState(ctx, tconn, ash.Closed); err != nil {81 s.Fatal("Launcher not closed after transition to clamshell mode: ", err)82 }83 }84 usingBubbleLauncher := productivityLauncher && !tabletMode85 // Open the Launcher and go to Apps list page.86 if usingBubbleLauncher {87 if err := launcher.OpenBubbleLauncher(tconn)(ctx); err != nil {88 s.Fatal("Failed to open bubble launcher: ", err)89 }90 } else {91 if err := launcher.OpenExpandedView(tconn)(ctx); err != nil {92 s.Fatal("Failed to open Expanded Application list view: ", err)93 }94 }95 if err := launcher.WaitForStableNumberOfApps(ctx, tconn); err != nil {96 s.Fatal("Failed to wait for item count in app list to stabilize: ", err)97 }98 if err := launcher.CreateFolder(ctx, tconn, productivityLauncher); err != nil {99 s.Fatal("Failed to create folder app: ", err)100 }101 // Add 5 app items to the folder.102 if err := launcher.AddItemsToFolder(ctx, tconn, launcher.UnnamedFolderFinder, 5, !usingBubbleLauncher); err != nil {103 s.Fatal("Failed to add items to folder: ", err)104 }105 // Check that the folder has 7 items.106 size, err := launcher.GetFolderSize(ctx, tconn, launcher.UnnamedFolderFinder)107 if err != nil {108 s.Fatal("Failed to get the folder size: ", err)109 }110 if size != 7 {111 s.Fatalf("Unexpected number of items in folder, got %d, want %d", size, 7)112 }113 // Remove 3 items from the folder.114 for i := 0; i < 3; i++ {115 if err := launcher.RemoveIconFromFolder(tconn, launcher.UnnamedFolderFinder)(ctx); err != nil {116 s.Fatal("Failed to remove icon from folder: ", err)117 }118 }119 // Check that the folder has 4 items.120 size, err = launcher.GetFolderSize(ctx, tconn, launcher.UnnamedFolderFinder)121 if err != nil {122 s.Fatal("Failed to get the folder size: ", err)123 }124 if size != 4 {125 s.Fatalf("Unexpected number of items in folder, got %d, want %d", size, 4)126 }127 // Remove 3 items from the folder.128 for i := 0; i < 3; i++ {129 if err := launcher.RemoveIconFromFolder(tconn, launcher.UnnamedFolderFinder)(ctx); err != nil {130 s.Fatal("Failed to remove icon from folder: ", err)131 }132 }133 // With productivity launcher enabled, launcher does not delete single-item folders, so the folder should be around until the last item is dragged out.134 if productivityLauncher {135 if err := launcher.RemoveIconFromFolder(tconn, launcher.UnnamedFolderFinder)(ctx); err != nil {136 s.Fatal("Failed to remove last icon from folder: ", err)137 }138 }139 // Check that there is no longer a folder.140 ui := uiauto.New(tconn)141 if err := ui.WaitUntilGone(launcher.UnnamedFolderFinder)(ctx); err != nil {142 s.Fatal("Folder exists when it should not: ", err)143 }144}...

Full Screen

Full Screen

create_and_fill_folder.go

Source:create_and_fill_folder.go Github

copy

Full Screen

1// Copyright 2021 The Chromium OS Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4package launcher5import (6 "context"7 "io/ioutil"8 "os"9 "time"10 "chromiumos/tast/local/chrome"11 "chromiumos/tast/local/chrome/ash"12 "chromiumos/tast/local/chrome/uiauto/launcher"13 "chromiumos/tast/testing"14 "chromiumos/tast/testing/hwdep"15)16func init() {17 testing.AddTest(&testing.Test{18 Func: CreateAndFillFolder,19 LacrosStatus: testing.LacrosVariantUnneeded,20 Desc: "Test adding items to a folder in the launcher",21 Contacts: []string{22 "cros-system-ui-eng@google.com",23 "chromeos-sw-engprod@google.com",24 "mmourgos@chromium.org"},25 Attr: []string{"group:mainline", "informational"},26 SoftwareDeps: []string{"chrome"},27 Timeout: 4 * time.Minute,28 Params: []testing.Param{{29 Name: "productivity_launcher_clamshell_mode",30 Val: launcher.TestCase{ProductivityLauncher: true, TabletMode: false},31 }, {32 Name: "clamshell_mode",33 Val: launcher.TestCase{ProductivityLauncher: false, TabletMode: false},34 }, {35 Name: "productivity_launcher_tablet_mode",36 Val: launcher.TestCase{ProductivityLauncher: true, TabletMode: true},37 ExtraHardwareDeps: hwdep.D(hwdep.InternalDisplay()),38 }, {39 Name: "tablet_mode",40 Val: launcher.TestCase{ProductivityLauncher: false, TabletMode: true},41 ExtraHardwareDeps: hwdep.D(hwdep.InternalDisplay()),42 }},43 })44}45// CreateAndFillFolder tests that a folder can be filled to the maximum allowed size.46func CreateAndFillFolder(ctx context.Context, s *testing.State) {47 extDirBase, err := ioutil.TempDir("", "")48 if err != nil {49 s.Fatal("Failed to create a temporary directory: ", err)50 }51 defer os.RemoveAll(extDirBase)52 // Create 50 fake apps and get the the options to add to the new chrome session.53 opts, err := ash.GeneratePrepareFakeAppsOptions(extDirBase, 50)54 if err != nil {55 s.Fatal("Failed to create 50 fake apps")56 }57 testCase := s.Param().(launcher.TestCase)58 productivityLauncher := testCase.ProductivityLauncher59 if productivityLauncher {60 opts = append(opts, chrome.EnableFeatures("ProductivityLauncher"))61 } else {62 opts = append(opts, chrome.DisableFeatures("ProductivityLauncher"))63 }64 // Creating fake apps and logging into a new session in this test ensures that enough apps will be available to folder.65 cr, err := chrome.New(ctx, opts...)66 if err != nil {67 s.Fatal("Chrome login failed: ", err)68 }69 defer cr.Close(ctx)70 tconn, err := cr.TestAPIConn(ctx)71 if err != nil {72 s.Fatal("Failed to connect to test API: ", err)73 }74 tabletMode := testCase.TabletMode75 cleanup, err := ash.EnsureTabletModeEnabled(ctx, tconn, tabletMode)76 if err != nil {77 s.Fatalf("Failed to ensure tablet mode state %t: %v", tabletMode, err)78 }79 defer cleanup(ctx)80 if !tabletMode {81 if err := ash.WaitForLauncherState(ctx, tconn, ash.Closed); err != nil {82 s.Fatal("Launcher not closed after transition to clamshell mode: ", err)83 }84 }85 usingBubbleLauncher := productivityLauncher && !tabletMode86 // Open the Launcher on the apps grid page.87 if usingBubbleLauncher {88 if err := launcher.OpenBubbleLauncher(tconn)(ctx); err != nil {89 s.Fatal("Failed to open bubble launcher: ", err)90 }91 } else {92 if err := launcher.OpenExpandedView(tconn)(ctx); err != nil {93 s.Fatal("Failed to open Expanded Application list view: ", err)94 }95 }96 if err := launcher.WaitForStableNumberOfApps(ctx, tconn); err != nil {97 s.Fatal("Failed to wait for item count in app list to stabilize: ", err)98 }99 if err := launcher.CreateFolder(ctx, tconn, productivityLauncher); err != nil {100 s.Fatal("Failed to create folder app: ", err)101 }102 // The folder already has 2 items. Add 46 more items to get to the maximum folder size of 48 apps.103 if err := launcher.AddItemsToFolder(ctx, tconn, launcher.UnnamedFolderFinder, 46, !usingBubbleLauncher); err != nil {104 s.Fatal("Failed to add items to folder: ", err)105 }106 // Check that the number of apps in the folder is 48.107 size, err := launcher.GetFolderSize(ctx, tconn, launcher.UnnamedFolderFinder)108 if err != nil {109 s.Fatal("Failed to get the folder size: ", err)110 }111 if size != 48 {112 s.Fatalf("Unexpected number of items in folder, got %d, want %d", size, 48)113 }114 // Attempt to add one more item to the folder.115 if err := launcher.AddItemsToFolder(ctx, tconn, launcher.UnnamedFolderFinder, 1, !usingBubbleLauncher); err != nil {116 s.Fatal("Failed to add items to folder: ", err)117 }118 // Because the folder was already filled to the maximum size, the number of apps in the folder should still be 48.119 // Check that the folder size remains at the max of 48.120 size, err = launcher.GetFolderSize(ctx, tconn, launcher.UnnamedFolderFinder)121 if err != nil {122 s.Fatal("Failed to get the folder size: ", err)123 }124 if size != 48 {125 s.Fatalf("Unexpected number of items in folder, got %d, want %d", size, 48)126 }127}...

Full Screen

Full Screen

smoke.go

Source:smoke.go Github

copy

Full Screen

...34 tconn, err := cr.TestAPIConn(ctx)35 if err != nil {36 s.Fatal("Failed to connect Test API: ", err)37 }38 defer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)39 // The test expects clamshell mode.40 cleanup, err := ash.EnsureTabletModeEnabled(ctx, tconn, false)41 if err != nil {42 s.Fatal("Failed to ensure clamshell mode: ", err)43 }44 defer cleanup(ctx)45 ui := uiauto.New(tconn)46 if err := ui.WithInterval(2*time.Second).WaitUntilNoEvent(nodewith.Root(), event.LocationChanged)(ctx); err != nil {47 s.Fatal("Failed to wait for location changes: ", err)48 }49 // Open peeking launcher using search key accelerator.50 if err := ash.TriggerLauncherStateChange(ctx, tconn, ash.AccelSearch); err != nil {51 s.Fatal("Failed to trigger launcher using search key: ", err)52 }...

Full Screen

Full Screen

Err

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 err = launch.Launch()4 if err != nil {5 fmt.Println(err)6 }7}8import (9func main() {10 err = launch.Launch()11 if err != nil {12 fmt.Println(err.Error())13 }14}15import (16func main() {17 err = launch.Launch()18 if err != nil {19 fmt.Println(err.String())20 }21}22import (23func main() {24 err = launch.Launch()25 if err != nil {26 fmt.Println(err.Error())27 }28}29import (30func main() {31 err = launch.Launch()32 if err != nil {33 fmt.Println(err.String())34 }35}36import (37func main() {38 err = launch.Launch()39 if err != nil {40 fmt.Println(err.Error())41 }42}43import (44func main() {45 err = launch.Launch()46 if err != nil {47 fmt.Println(err.String())48 }49}50import (51func main() {52 err = launch.Launch()53 if err != nil {54 fmt.Println(err.Error())55 }56}

Full Screen

Full Screen

Err

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 config := ldrelay.Config{}4 launcher := ldrelay.NewLauncher(config)5 err := launcher.Err()6 fmt.Println(err)7}8./2.go:11:3: cannot use launcher.Err() (type error) as type string in assignment9func getTest(w http.ResponseWriter, r *http.Request) {10 w.Header().Set("Content-Type", "application/json")11 w.WriteHeader(http.StatusOK)12 w.Write([]byte(`{"message": "test"}`))13}14func TestGetTest(t *testing.T) {15 req, err := http.NewRequest("GET", "/test", nil)16 if err != nil {17 t.Fatal(err)18 }19 rr := httptest.NewRecorder()20 handler := http.HandlerFunc(getTest)21 handler.ServeHTTP(rr, req)22 if status := rr.Code; status != http.StatusOK {23 t.Errorf("handler returned wrong status code: got %v want %v",24 }25 expected := `{"message": "test"}`26 if rr.Body.String() != expected {27 t.Errorf("handler returned unexpected body: got %v want %v",28 rr.Body.String(), expected)29 }30}31--- FAIL: TestGetTest (0.00s)32func getTest(w http.ResponseWriter, r *http.Request) {33 w.Header().Set("Content-Type", "application/json")34 w.WriteHeader(http.StatusOK)35 w.Write([]byte(`{"message": "test"}`))36}37func TestGetTest(t *testing.T) {

Full Screen

Full Screen

Err

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello")4 l := launcher.Launcher{}5 l.Err()6}7import (8type Launcher struct {9}10func (l *Launcher) Err() {11 fmt.Println("Error")12}13 /usr/local/Cellar/go/1.7.1/libexec/src/launcher (from $GOROOT)14 /Users/rohit/go/src/launcher (from $GOPATH)

Full Screen

Full Screen

Err

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Error returned by launcher class is :", launcher.Err())4}5import (6func main() {7 fmt.Println("Error returned by launcher class is :", launcher.Err())8}9import (10func main() {11 fmt.Println("Error returned by

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful