| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "chrome/browser/extensions/api/serial/serial_api.h" | 6 #include "chrome/browser/extensions/api/serial/serial_api.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 catcher.RestrictToProfile(browser()->profile()); | 26 catcher.RestrictToProfile(browser()->profile()); |
| 27 | 27 |
| 28 ExtensionTestMessageListener listener("serial_port", true); | 28 ExtensionTestMessageListener listener("serial_port", true); |
| 29 | 29 |
| 30 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("serial/api"))); | 30 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("serial/api"))); |
| 31 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 31 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 32 | 32 |
| 33 #if 0 | 33 #if 0 |
| 34 // Enable this path only if all the following are true: | 34 // Enable this path only if all the following are true: |
| 35 // | 35 // |
| 36 // 1. You're running Linux. | 36 // 1. You have an Adafruit Atmega32u4 Breakout Board attached to your machine |
| 37 // and properly appearing as the first virtual serial port ("first" is very |
| 38 // loosely defined as whichever port shows up in serial.getPorts). Other |
| 39 // devices will work, but this is the only one tested. |
| 37 // | 40 // |
| 38 // 2. You have an Adafruit ATmega32u4 breakout board attached to your machine | 41 // 2. Your user has permission to read/write the port. For example, this might |
| 39 // via USB with the Arduino Leonardo bootloader flashed to the board. Other | 42 // mean that your user is in the "tty" group on Ubuntu flavors of Linux, or |
| 40 // devices will work; this is the only one tested. | 43 // else that /dev/ttyACM0 has global read/write permissions. |
| 41 // | 44 // |
| 42 // 3. Your user has permission to read/write the /dev/ttyACM0 device. | 45 // 4. You have uploaded a program to the board that does a byte-for-byte echo |
| 43 // | |
| 44 // 4. You have uploaded a program to the '32u4 that does a byte-for-byte echo | |
| 45 // on the virtual serial port at 57600 bps. Here is an example (built using | 46 // on the virtual serial port at 57600 bps. Here is an example (built using |
| 46 // the Arduino IDE): | 47 // the Arduino IDE): |
| 47 // | 48 // |
| 48 // void setup() { | 49 // void setup() { |
| 49 // Serial.begin(57600); | 50 // Serial.begin(57600); |
| 50 // } | 51 // } |
| 51 // | 52 // |
| 52 // void loop() { | 53 // void loop() { |
| 53 // while (true) { | 54 // while (true) { |
| 54 // while (Serial.available() > 0) { | 55 // while (Serial.available() > 0) { |
| 55 // Serial.print((char)Serial.read()); | 56 // Serial.print((char)Serial.read()); |
| 56 // } | 57 // } |
| 57 // } | 58 // } |
| 58 // } | 59 // } |
| 59 // | 60 listener.Reply("echo_device_attached"); |
| 60 // TODO(miket): Enable a more forgiving set of test conditions, specifically | |
| 61 // by mocking SerialConnection. | |
| 62 listener.Reply("/dev/ttyACM0"); | |
| 63 #else | 61 #else |
| 64 listener.Reply("none"); | 62 listener.Reply("false"); |
| 65 #endif | 63 #endif |
| 66 | 64 |
| 67 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 65 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 68 } | 66 } |
| OLD | NEW |